{"challengeId":"golomb-12","entry":"verifier.mjs","sha256":"9ba48f40a2fe90b33a36460d09f19510d937793b62ad6b0b2957036621a9e50a","scoreDirection":"minimize","scoreLabel":"length","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for golomb-12. Self-contained (no imports): it interprets the\n// candidate's ruler artifact and returns a Verdict. It never executes agent code\n// — build() already ran in the sandbox and handed us plain data. This file is\n// part of the challenge's PROTECTED surface.\n//\n// Identical to golomb-11's verifier with one constant changed: N = 12.\n// A Golomb ruler of order N is a set of N integer marks whose N*(N-1)/2 pairwise\n// differences are all DISTINCT. Correctness is decided exhaustively by collecting\n// every pairwise difference and proving they are unique — there is no hidden test\n// set and nothing to overfit, so seedPolicy.mode is \"fixed\".\n\nconst N = 12;\nconst MAX_LENGTH = 1_000_000;\n\nfunction gate(name, pass, detail) {\n  return { name, pass, detail };\n}\nfunction bad(name, detail) {\n  return { ok: false, score: null, gates: [gate(name, false, detail)], behavior: {}, logs: [] };\n}\n\nexport function verify(ctx) {\n  const sol = ctx.solution;\n  if (!sol || typeof sol !== 'object' || !Array.isArray(sol.marks)) {\n    return bad('structure', 'expected { marks: [m0, m1, ...] }');\n  }\n  const marks = sol.marks;\n  if (marks.length !== N) {\n    return bad('structure', `expected exactly ${N} marks, got ${marks.length}`);\n  }\n  for (let i = 0; i < N; i++) {\n    if (!Number.isInteger(marks[i]) || marks[i] < 0 || marks[i] > MAX_LENGTH) {\n      return bad('structure', `mark ${i} must be an integer in 0..${MAX_LENGTH}`);\n    }\n  }\n\n  // Marks must be in strictly ascending order and start at 0 (canonical form).\n  if (marks[0] !== 0) {\n    return bad('canonical', 'the first mark must be 0');\n  }\n  for (let i = 1; i < N; i++) {\n    if (marks[i] <= marks[i - 1]) {\n      return bad('canonical', `marks must strictly increase (mark ${i} = ${marks[i]} ≤ ${marks[i - 1]})`);\n    }\n  }\n\n  // The Golomb property: every pairwise difference is distinct.\n  const seen = new Set();\n  let collision = '';\n  for (let i = 0; i < N && !collision; i++) {\n    for (let j = i + 1; j < N; j++) {\n      const d = marks[j] - marks[i];\n      if (seen.has(d)) {\n        collision = `distance ${d} occurs more than once`;\n        break;\n      }\n      seen.add(d);\n    }\n  }\n  const expectedPairs = (N * (N - 1)) / 2;\n  const distinct = !collision && seen.size === expectedPairs;\n\n  const length = marks[N - 1];\n  const firstGap = marks[1] - marks[0];\n  const gates = [\n    gate('distinct-differences', distinct, collision || `all ${expectedPairs} pairwise distances are distinct`),\n  ];\n  const ok = gates.every((g) => g.pass);\n  return {\n    ok,\n    score: ok ? length : null,\n    gates,\n    behavior: { length, firstGap },\n    logs: [`length=${length} firstGap=${firstGap} pairs=${seen.size}`],\n  };\n}\n"}