{"challengeId":"vdw-w27","entry":"verifier.mjs","sha256":"cb513f555aeaabbe079412d476781ad144ea91b26da657580bbc1148e38c3437","scoreDirection":"maximize","scoreLabel":"integers","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for vdw-w27 (van der Waerden W(2,7) foothold).\n//\n// The instance is a pure mathematical rule — there is no embedded data table.\n// You submit a 2-coloring of the integers 1..N:  { n: N, color: [c_1, ..., c_N] }\n// where each c_i is 0 or 1 (the color of integer i, 1-indexed; color[0] is the\n// color of the integer 1).\n//\n// VALID  <=> the coloring contains NO monochromatic 7-term arithmetic progression:\n//            for every start a and common difference d with a + 6d <= N, the seven\n//            integers a, a+d, a+2d, ..., a+6d are NOT all the same color.\n//\n// Score = N (the number of consecutive integers colored). MAXIMIZE N.\n//\n// This is the van der Waerden frontier: W(2,7) is the least N such that EVERY\n// 2-coloring of 1..N is forced to contain a monochromatic 7-term AP. The exact\n// value of W(2,7) is an OPEN problem; the best published lower bound shows a valid\n// 2-coloring of 1..3703 exists (so W(2,7) > 3703). Any valid coloring is a concrete,\n// replayable foothold: a longer one pushes the lower bound; the verifier re-derives\n// every AP and confirms none is monochromatic.\n//\n// Pure integer / index arithmetic — deterministic; seedPolicy \"fixed\". The scan is\n// O(N^2) in the number of (a,d) pairs; N is bounded to keep the worst case well\n// under the timeout.\n\nconst N_MAX = 6000;\n\nfunction gate(name, pass, detail) { return { name, pass, detail }; }\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 && ctx.solution;\n  if (!sol || typeof sol !== 'object') {\n    return bad('structure', 'expected { n: N, color: [N values, each 0 or 1] }');\n  }\n\n  const n = sol.n;\n  if (!Number.isInteger(n) || n < 7 || n > N_MAX) {\n    return bad('structure', `n must be an integer in [7, ${N_MAX}]; got ${String(n)}`);\n  }\n\n  const color = sol.color;\n  if (!Array.isArray(color) || color.length !== n) {\n    return bad('structure', `color must be an array of exactly n=${n} entries; got length ${Array.isArray(color) ? color.length : 'non-array'}`);\n  }\n  for (let i = 0; i < n; i++) {\n    const c = color[i];\n    if (c !== 0 && c !== 1) {\n      return bad('structure', `color[${i}] must be 0 or 1; got ${String(c)}`);\n    }\n  }\n\n  // Scan every 7-term AP: a, a+d, ..., a+6d with a + 6d <= n (1-indexed integers).\n  // color[k-1] is the color of integer k.\n  let apCount = 0;\n  for (let d = 1; 1 + 6 * d <= n; d++) {\n    const step6 = 6 * d;\n    for (let a = 1; a + step6 <= n; a++) {\n      const c0 = color[a - 1];\n      if (\n        color[a + d - 1] === c0 &&\n        color[a + 2 * d - 1] === c0 &&\n        color[a + 3 * d - 1] === c0 &&\n        color[a + 4 * d - 1] === c0 &&\n        color[a + 5 * d - 1] === c0 &&\n        color[a + step6 - 1] === c0\n      ) {\n        return bad(\n          'no-mono-7AP',\n          `monochromatic 7-term AP found: start a=${a}, step d=${d}, color=${c0} (terms ${a},${a + d},${a + 2 * d},${a + 3 * d},${a + 4 * d},${a + 5 * d},${a + step6})`,\n        );\n      }\n      apCount++;\n    }\n  }\n\n  return {\n    ok: true,\n    score: n,\n    gates: [gate('no-mono-7AP', true, `valid 2-coloring of 1..${n}; checked ${apCount} arithmetic progressions, none monochromatic`)],\n    behavior: { n },\n    logs: [`n=${n}`, `arithmetic-progressions-checked=${apCount}`],\n  };\n}\n"}