{"challengeId":"labs-67","entry":"verifier.mjs","sha256":"61ce3693cb15fec735c20aa2a37a98ad280c4023745a1afa9f27e969c813cf00","scoreDirection":"minimize","scoreLabel":"sidelobe energy","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for labs-67 — Low-Autocorrelation Binary Sequences, length 67.\n// Self-contained (no imports). The instance IS the length: a binary sequence of\n// N = 67 entries, each in {-1, +1}. The agent submits the sequence; the checker\n// scores the aperiodic autocorrelation SIDELOBE ENERGY\n//\n//     E = Sum_{k=1..66} C_k^2 ,   C_k = Sum_{i=0..66-k} seq[i] * seq[i+k]\n//\n// which it MINIMIZES. Every C_k is an exact integer and E is an exact integer,\n// so the score is bit-reproducible — no transcendental math, deterministic,\n// seedPolicy \"fixed\". (The merit factor N^2 / (2E) is a DISPLAY convenience only;\n// the scored quantity is the pure-integer energy E.)\n//\n// Lengths N <= 66 are exhaustively solved (Packebusch & Mertens 2016, an\n// Theta(N * 1.73^N) branch-and-bound). N = 67 sits just past that exhaustive\n// frontier: its minimal E is a best-known, improvable board record, not a proven\n// optimum — which is exactly what makes a lower E here a real result.\n\nconst N = 67;\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 sol = ctx && typeof ctx === 'object' ? ctx.solution : undefined;\n  const seq = sol && typeof sol === 'object' ? sol.seq : undefined;\n\n  if (!Array.isArray(seq) || seq.length !== N) {\n    return bad('structure', `expected { seq: [${N} values, each -1 or +1] }`);\n  }\n  for (let i = 0; i < N; i++) {\n    const v = seq[i];\n    if (v !== 1 && v !== -1) {\n      return bad('structure', `seq[${i}] must be -1 or +1; got ${String(v)}`);\n    }\n  }\n\n  // Aperiodic autocorrelation sidelobe energy — pure integer arithmetic.\n  let E = 0;\n  let peakAbs = 0;\n  for (let k = 1; k < N; k++) {\n    let c = 0;\n    for (let i = 0; i + k < N; i++) c += seq[i] * seq[i + k];\n    E += c * c;\n    const a = c < 0 ? -c : c;\n    if (a > peakAbs) peakAbs = a;\n  }\n\n  // Merit factor for DISPLAY only (integer-scaled to avoid any float decision):\n  // mf100 = round(100 * N^2 / (2E)). Never used in the pass/fail or the score.\n  const mf100 = E > 0 ? Math.round((100 * N * N) / (2 * E)) : 0;\n\n  return {\n    ok: true,\n    score: E,\n    gates: [gate('valid-sequence', true, `sidelobe energy E=${E} (peak |C_k|=${peakAbs}, merit factor ~${mf100 / 100}) over length ${N}`)],\n    behavior: { energy: E },\n    logs: [`E=${E}`, `peakAbs=${peakAbs}`],\n  };\n}\n"}