{"challengeId":"schur-6","entry":"verifier.mjs","sha256":"5afcc872c8384049af246f8dd75cefaae49060ca4c1f1eb327ab4367d1e2c488","scoreDirection":"maximize","scoreLabel":"integers","seedPolicy":{"mode":"fixed","testCount":1},"source":"// Frozen verifier for schur-6. Self-contained (no imports, no external data).\n// THE INSTANCE IS A MATH RULE, not embedded data: partition the integers 1..N into\n// 6 colors (0..5) so that EVERY color class is SUM-FREE — within one color there is\n// NO solution to x + y = z (x = y allowed). This is the Schur-number frontier: the\n// Schur number S(6) is the largest N for which such a 6-coloring of 1..N exists.\n// The agent picks N and a color for each integer 1..N; score = N (MAXIMIZE).\n//\n// Verification is pure integer arithmetic — for each color we scan every pair x<=y\n// of same-colored integers and check whether x+y (when <= N) is also that color.\n// O(N^2) over a bounded N (<= 2000), comfortably under timeoutMs. Deterministic,\n// no floats, nothing hidden — seedPolicy.mode is \"fixed\".\n\nconst COLORS = 6;\nconst N_MAX = 2000; // hard bound so worst-case O(N^2) stays well under the timeout\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 && typeof ctx.solution === 'object' ? ctx.solution : null;\n  if (!sol) return bad('structure', 'expected { n: N, color: int[N] }');\n\n  const n = sol.n;\n  if (!Number.isInteger(n) || n < 1 || n > N_MAX) {\n    return bad('structure', `n must be an integer in 1..${N_MAX}; got ${String(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 (one per integer 1..n)`);\n  }\n  // color[i] is the color of integer i+1 (0-indexed array, integers are 1-based).\n  for (let i = 0; i < n; i++) {\n    const c = color[i];\n    if (!Number.isInteger(c) || c < 0 || c >= COLORS) {\n      return bad('structure', `color of integer ${i + 1} must be an integer in 0..${COLORS - 1}; got ${String(c)}`);\n    }\n  }\n\n  // Group integers 1..n by color, then check sum-free within each color class.\n  // inColor[c] is a flag array indexed by integer value (1..n).\n  const inColor = [];\n  for (let c = 0; c < COLORS; c++) inColor.push(new Uint8Array(n + 1));\n  for (let i = 0; i < n; i++) inColor[color[i]][i + 1] = 1;\n\n  for (let c = 0; c < COLORS; c++) {\n    const flag = inColor[c];\n    // gather members of this color in ascending order\n    const members = [];\n    for (let v = 1; v <= n; v++) if (flag[v] === 1) members.push(v);\n    // check every pair x <= y; if x+y <= n and x+y is also this color -> violation\n    for (let a = 0; a < members.length; a++) {\n      const x = members[a];\n      for (let b = a; b < members.length; b++) {\n        const z = x + members[b];\n        if (z > n) break; // members sorted ascending; further y only grows z\n        if (flag[z] === 1) {\n          return bad(\n            'sum-free',\n            `color ${c} is not sum-free: ${x} + ${members[b]} = ${z}, all colored ${c}`,\n          );\n        }\n      }\n    }\n  }\n\n  return {\n    ok: true,\n    score: n,\n    gates: [gate('sum-free', true, `all ${COLORS} color classes are sum-free over integers 1..${n}`)],\n    behavior: { n },\n    logs: [`valid sum-free 6-coloring of 1..${n}; score n=${n}`],\n  };\n}\n"}