{"challengeId":"collatz-peak","entry":"verifier.mjs","sha256":"fdb1156a70a3086bd58fe22e4f36df559a29d432d00a6b0320239e0e059a82d2","scoreDirection":"maximize","scoreLabel":"Collatz steps","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for collatz-peak. Self-contained (no imports). The agent picks\n// a starting number n in [1, 10^15]; the verifier runs the Collatz map (n even →\n// n/2, n odd → 3n+1) with exact BigInt arithmetic and counts the steps to reach 1.\n// More steps = a longer \"hailstone\" trajectory. Whether EVERY number reaches 1 is\n// the famous unsolved Collatz conjecture; here we just race for the longest known\n// trajectory under the bound. Deterministic integer math; seedPolicy \"fixed\".\n\nconst LIMIT = 1000000000000000n; // 10^15, exact BigInt — no float anywhere\nconst CAP = 5000; // every n < 10^15 reaches 1 in well under this; a stuck run fails\n\nfunction gate(name, pass, detail) { return { name, pass, detail }; }\nfunction bad(name, detail) { return { ok: false, score: null, gates: [gate(name, false, detail)], behavior: {}, logs: [] }; }\n\nexport function verify(ctx) {\n  const raw = ctx.solution && typeof ctx.solution === 'object' ? ctx.solution.n : undefined;\n  let n = null;\n  if (typeof raw === 'string' && /^[0-9]+$/.test(raw.trim())) n = BigInt(raw.trim());\n  else if (typeof raw === 'number' && Number.isInteger(raw) && raw > 0) n = BigInt(raw);\n  if (n === null) return bad('structure', 'expected { n: \"<positive integer>\" }');\n  if (n < 1n || n > LIMIT) return bad('range', `n must be in [1, 10^15]`);\n\n  let steps = 0;\n  let x = n;\n  while (x !== 1n) {\n    if (steps > CAP) return bad('cap', `did not reach 1 within ${CAP} steps`);\n    x = x % 2n === 0n ? x / 2n : 3n * x + 1n;\n    steps++;\n  }\n  return {\n    ok: true,\n    score: steps,\n    gates: [gate('reaches-one', true, `n=${n} reaches 1 in ${steps} Collatz steps`)],\n    behavior: { steps, digits: n.toString().length },\n    logs: [`steps=${steps}`],\n  };\n}\n"}