From d0bc3b95dde0caa65205023e223bf5793c9a0ced Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 7 Nov 2025 21:32:49 +0000 Subject: [PATCH] Docs: Update benchmark results --- results.json | 80 +++++++----- .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 28 +++++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 42 +++---- .../outputs/anthropic_claude-sonnet-4.5.js | 34 +++--- .../outputs/google_gemini-2.5-pro TEMP_0.4.js | 27 ---- .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 30 +++-- .../outputs/google_gemini-2.5-pro.js | 32 ----- .../1_dijkstra/outputs/openai_gpt-5-codex.js | 49 ++++---- .../outputs/openrouter_polaris-alpha.js | 24 ++++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 10 +- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 11 +- .../outputs/anthropic_claude-sonnet-4.5.js | 14 +-- .../outputs/google_gemini-2.5-pro TEMP_0.4.js | 33 ----- .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 31 ++--- .../outputs/google_gemini-2.5-pro.js | 35 ------ .../outputs/openai_gpt-5-codex.js | 38 +++--- .../outputs/openrouter_polaris-alpha.js | 29 +++++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 4 +- .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 8 +- .../outputs/anthropic_claude-sonnet-4.5.js | 12 +- .../outputs/google_gemini-2.5-pro TEMP_0.4.js | 14 --- .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 16 +-- tests/3_lis/outputs/google_gemini-2.5-pro.js | 13 -- tests/3_lis/outputs/openai_gpt-5-codex.js | 24 ++-- .../3_lis/outputs/openrouter_polaris-alpha.js | 12 ++ .../outputs/google_gemini-2.5-pro TEMP_0.4.js | 5 - .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 6 +- .../outputs/google_gemini-2.5-pro.js | 5 - .../outputs/openai_gpt-5-codex.js | 8 +- .../outputs/openrouter_polaris-alpha.js | 7 ++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 5 + .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 5 + .../outputs/anthropic_claude-sonnet-4.5.js | 5 + .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 5 + .../outputs/openai_gpt-5-codex.js | 15 +++ .../outputs/openrouter_polaris-alpha.js | 11 ++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 26 ++++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 30 +++++ .../outputs/anthropic_claude-sonnet-4.5.js | 30 +++++ .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 40 ++++++ .../outputs/openai_gpt-5-codex.js | 20 +++ .../outputs/openrouter_polaris-alpha.js | 30 +++++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 78 ++++++++++++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 93 ++++++++++++++ .../outputs/anthropic_claude-sonnet-4.5.js | 74 +++++++++++ .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 56 +++++++++ .../7_scheduler/outputs/openai_gpt-5-codex.js | 55 +++++++++ .../outputs/openrouter_polaris-alpha.js | 115 ++++++++++++++++++ .../anthropic_claude-sonnet-4.5 TEMP_0.4.js | 18 +++ .../anthropic_claude-sonnet-4.5 TEMP_0.7.js | 16 +++ .../outputs/anthropic_claude-sonnet-4.5.js | 15 +++ .../outputs/google_gemini-2.5-pro TEMP_0.7.js | 32 +++++ .../outputs/openai_gpt-5-codex.js | 17 +++ .../outputs/openrouter_polaris-alpha.js | 15 +++ 54 files changed, 1115 insertions(+), 372 deletions(-) create mode 100644 tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js delete mode 100644 tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js delete mode 100644 tests/1_dijkstra/outputs/google_gemini-2.5-pro.js create mode 100644 tests/1_dijkstra/outputs/openrouter_polaris-alpha.js delete mode 100644 tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.4.js delete mode 100644 tests/2_convex_hull/outputs/google_gemini-2.5-pro.js create mode 100644 tests/2_convex_hull/outputs/openrouter_polaris-alpha.js delete mode 100644 tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js delete mode 100644 tests/3_lis/outputs/google_gemini-2.5-pro.js create mode 100644 tests/3_lis/outputs/openrouter_polaris-alpha.js delete mode 100644 tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.4.js delete mode 100644 tests/4_determinant/outputs/google_gemini-2.5-pro.js create mode 100644 tests/4_determinant/outputs/openrouter_polaris-alpha.js create mode 100644 tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js create mode 100644 tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js create mode 100644 tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5.js create mode 100644 tests/5_markdown_parser/outputs/google_gemini-2.5-pro TEMP_0.7.js create mode 100644 tests/5_markdown_parser/outputs/openai_gpt-5-codex.js create mode 100644 tests/5_markdown_parser/outputs/openrouter_polaris-alpha.js create mode 100644 tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js create mode 100644 tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js create mode 100644 tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5.js create mode 100644 tests/6_csv_processor/outputs/google_gemini-2.5-pro TEMP_0.7.js create mode 100644 tests/6_csv_processor/outputs/openai_gpt-5-codex.js create mode 100644 tests/6_csv_processor/outputs/openrouter_polaris-alpha.js create mode 100644 tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js create mode 100644 tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js create mode 100644 tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5.js create mode 100644 tests/7_scheduler/outputs/google_gemini-2.5-pro TEMP_0.7.js create mode 100644 tests/7_scheduler/outputs/openai_gpt-5-codex.js create mode 100644 tests/7_scheduler/outputs/openrouter_polaris-alpha.js create mode 100644 tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js create mode 100644 tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js create mode 100644 tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5.js create mode 100644 tests/8_json_validator/outputs/google_gemini-2.5-pro TEMP_0.7.js create mode 100644 tests/8_json_validator/outputs/openai_gpt-5-codex.js create mode 100644 tests/8_json_validator/outputs/openrouter_polaris-alpha.js diff --git a/results.json b/results.json index 2bac9bf..0bc7861 100644 --- a/results.json +++ b/results.json @@ -1,44 +1,62 @@ { - "google/gemini-2.5-pro": { - "1_dijkstra": 37.563614472, - "2_convex_hull": 30.02974868399999, - "3_lis": 42.240308332, - "4_determinant": 13.347867265000009 + "openrouter/polaris-alpha": { + "1_dijkstra": 5.063492935, + "2_convex_hull": 7.998615312, + "3_lis": 2.2021910790000003, + "4_determinant": 2.4727166589999996, + "5_markdown_parser": 2.1889706240000013, + "6_csv_processor": 6.424773092, + "7_scheduler": 19.749020437, + "8_json_validator": 3.7860971980000033 }, "google/gemini-2.5-pro TEMP:0.7": { - "1_dijkstra": 57.442001282000014, - "2_convex_hull": 94.02301281699998, - "3_lis": 11.979348513000005, - "4_determinant": 12.74124894999998 - }, - "google/gemini-2.5-pro TEMP:0.4": { - "1_dijkstra": 47.84090968399995, - "2_convex_hull": 42.86752973399998, - "3_lis": 27.62078084000002, - "4_determinant": 8.960109082999988 + "1_dijkstra": 30.986608248000003, + "2_convex_hull": 58.090286611, + "3_lis": 39.50342178599999, + "4_determinant": 21.314621672999987, + "5_markdown_parser": 21.140068067999994, + "6_csv_processor": 46.383014058, + "7_scheduler": 74.787878823, + "8_json_validator": 39.59319957399997 }, "anthropic/claude-sonnet-4.5": { - "1_dijkstra": 13.460692856000039, - "2_convex_hull": 5.613852328000008, - "3_lis": 2.8292644480000018, - "4_determinant": 3.0375356369999937 + "1_dijkstra": 4.355259537999983, + "2_convex_hull": 4.980808106000011, + "3_lis": 2.2764143039999762, + "4_determinant": 1.8504535560000221, + "5_markdown_parser": 1.841865622000012, + "6_csv_processor": 4.9831007339999775, + "7_scheduler": 12.904369474000006, + "8_json_validator": 2.7832529310000247 }, "anthropic/claude-sonnet-4.5 TEMP:0.7": { - "1_dijkstra": 5.0235283530000014, - "2_convex_hull": 5.469308726000017, - "3_lis": 2.9667647899999867, - "4_determinant": 6.369721143000002 + "1_dijkstra": 3.933310278000019, + "2_convex_hull": 4.819035326000012, + "3_lis": 2.34827887899999, + "4_determinant": 1.644420714000007, + "5_markdown_parser": 2.280882503999979, + "6_csv_processor": 4.7151394149999835, + "7_scheduler": 13.658607328000013, + "8_json_validator": 3.4110046910000382 }, "anthropic/claude-sonnet-4.5 TEMP:0.4": { - "1_dijkstra": null, - "2_convex_hull": 6.095885308999976, - "3_lis": 3.749924349999987, - "4_determinant": 12.665039036000032 + "1_dijkstra": 3.954044443999999, + "2_convex_hull": 4.5914942489999815, + "3_lis": 2.4153946509999806, + "4_determinant": 1.7196861260000151, + "5_markdown_parser": 1.801734215000004, + "6_csv_processor": 4.646366793999972, + "7_scheduler": 12.781063763999962, + "8_json_validator": 3.3014615179999964 }, "openai/gpt-5-codex": { - "1_dijkstra": 97.35094948799996, - "2_convex_hull": 145.25300972899993, - "3_lis": 53.988241607000006, - "4_determinant": 6.342495287999976 + "1_dijkstra": 36.88321140999993, + "2_convex_hull": 26.59820080500003, + "3_lis": 12.8049466599999, + "4_determinant": 10.523928330000023, + "5_markdown_parser": 57.74550891099998, + "6_csv_processor": 105.18542238100001, + "7_scheduler": 127.650813921, + "8_json_validator": 24.58168081499997 } } \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js new file mode 100644 index 0000000..f249712 --- /dev/null +++ b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -0,0 +1,28 @@ +async function findShortestPath(graph, start, end) { + const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue'); + + const distances = {}; + const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist }); + + for (const node in graph) distances[node] = Infinity; + distances[start] = 0; + pq.queue({ node: start, dist: 0 }); + + while (pq.length) { + const { node, dist } = pq.dequeue(); + + if (node === end) return dist; + if (dist > distances[node]) continue; + + for (const neighbor in graph[node]) { + const newDist = dist + graph[node][neighbor]; + if (newDist < distances[neighbor]) { + distances[neighbor] = newDist; + pq.queue({ node: neighbor, dist: newDist }); + } + } + } + + return distances[end]; +} +export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 2cdcecd..a7afc4b 100644 --- a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,35 +1,29 @@ async function findShortestPath(graph, start, end) { - const { default: PriorityQueue } = await import( - 'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm' - ); - - const distances = Object.keys(graph).reduce((acc, node) => { - acc[node] = node === start ? 0 : Infinity; - return acc; - }, {}); - - const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist }); - pq.queue({ node: start, dist: 0 }); - + const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue'); + + const dist = { [start]: 0 }; + const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] }); const visited = new Set(); - + + pq.queue([start, 0]); + while (pq.length) { - const { node, dist } = pq.dequeue(); - + const [node, d] = pq.dequeue(); + if (visited.has(node)) continue; visited.add(node); - - if (node === end) return dist; - + + if (node === end) return d; + for (const [neighbor, weight] of Object.entries(graph[node] || {})) { - const newDist = dist + weight; - if (newDist < distances[neighbor]) { - distances[neighbor] = newDist; - pq.queue({ node: neighbor, dist: newDist }); + const newDist = d + weight; + if (newDist < (dist[neighbor] ?? Infinity)) { + dist[neighbor] = newDist; + pq.queue([neighbor, newDist]); } } } - - return distances[end]; + + return Infinity; } export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5.js b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5.js index 68c6bef..9e65ce0 100644 --- a/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5.js +++ b/tests/1_dijkstra/outputs/anthropic_claude-sonnet-4.5.js @@ -1,26 +1,22 @@ -const findShortestPath = async (graph, start, end) => { - const { default: PriorityQueue } = await import( - 'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm' - ); - - const distances = Object.keys(graph).reduce((acc, node) => { - acc[node] = node === start ? 0 : Infinity; - return acc; - }, {}); - +async function findShortestPath(graph, start, end) { + const { default: PriorityQueue } = await import('https://cdn.skypack.dev/js-priority-queue'); + + const distances = Object.keys(graph).reduce((acc, node) => ({ ...acc, [node]: Infinity }), {}); + distances[start] = 0; + const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist }); - const visited = new Set(); - pq.queue({ node: start, dist: 0 }); - + + const visited = new Set(); + while (pq.length) { const { node, dist } = pq.dequeue(); - + if (visited.has(node)) continue; - if (node === end) return dist; - visited.add(node); - + + if (node === end) return dist; + for (const [neighbor, weight] of Object.entries(graph[node] || {})) { const newDist = dist + weight; if (newDist < distances[neighbor]) { @@ -29,7 +25,7 @@ const findShortestPath = async (graph, start, end) => { } } } - + return distances[end]; -}; +} export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js b/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js deleted file mode 100644 index b1a634e..0000000 --- a/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js +++ /dev/null @@ -1,27 +0,0 @@ -async function findShortestPath(graph, startNode, endNode) { - const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'); - - const distances = { [startNode]: 0 }; - const pq = new PriorityQueue({ comparator: (a, b) => a.dist - b.dist }); - - pq.queue({ node: startNode, dist: 0 }); - - while (pq.length) { - const { node: u, dist: uDist } = pq.dequeue(); - - if (u === endNode) return uDist; - if (uDist > (distances[u] ?? Infinity)) continue; - - for (const v in graph[u] || {}) { - const newDist = uDist + graph[u][v]; - - if (newDist < (distances[v] ?? Infinity)) { - distances[v] = newDist; - pq.queue({ node: v, dist: newDist }); - } - } - } - - return Infinity; -} -export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js index 2fa0853..256b59c 100644 --- a/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js +++ b/tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -1,27 +1,33 @@ -async function findShortestPath(graph, startNode, endNode) { - const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'); +const findShortestPath = async (graph, start, end) => { + const cdn = 'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'; + const { default: PriorityQueue } = await import(cdn); - const distances = { [startNode]: 0 }; - const pq = new PriorityQueue({ comparator: (a, b) => a.priority - b.priority }); + const distances = Object.fromEntries( + Object.keys(graph).map(node => [node, Infinity]) + ); + distances[start] = 0; - pq.queue({ value: startNode, priority: 0 }); + const pq = new PriorityQueue({ + comparator: (a, b) => a.priority - b.priority + }); + pq.queue({ value: start, priority: 0 }); while (pq.length) { - const { value: currentNode } = pq.dequeue(); + const { value: current } = pq.dequeue(); - if (currentNode === endNode) break; + if (current === end) break; - const neighbors = graph[currentNode] ?? {}; + const neighbors = graph[current] || {}; for (const [neighbor, weight] of Object.entries(neighbors)) { - const newDist = distances[currentNode] + weight; + const newDist = distances[current] + weight; - if (newDist < (distances[neighbor] ?? Infinity)) { + if (newDist < distances[neighbor]) { distances[neighbor] = newDist; pq.queue({ value: neighbor, priority: newDist }); } } } - return distances[endNode] ?? Infinity; -} + return distances[end]; +}; export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js b/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js deleted file mode 100644 index 8c19321..0000000 --- a/tests/1_dijkstra/outputs/google_gemini-2.5-pro.js +++ /dev/null @@ -1,32 +0,0 @@ -const findShortestPath = async (graph, start, end) => { - const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'); - - const dist = { [start]: 0 }; - const pq = new PriorityQueue({ comparator: (a, b) => a.weight - b.weight }); - - pq.enqueue({ node: start, weight: 0 }); - - while (pq.length) { - const { node: u, weight: uWeight } = pq.dequeue(); - - if (uWeight > (dist[u] ?? Infinity)) { - continue; - } - - if (u === end) { - return uWeight; - } - - for (const v in graph[u] || {}) { - const newWeight = uWeight + graph[u][v]; - - if (newWeight < (dist[v] ?? Infinity)) { - dist[v] = newWeight; - pq.enqueue({ node: v, weight: newWeight }); - } - } - } - - return Infinity; -}; -export default findShortestPath; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/openai_gpt-5-codex.js b/tests/1_dijkstra/outputs/openai_gpt-5-codex.js index c83adae..8cfe929 100644 --- a/tests/1_dijkstra/outputs/openai_gpt-5-codex.js +++ b/tests/1_dijkstra/outputs/openai_gpt-5-codex.js @@ -1,29 +1,24 @@ -let u; -const loadQueue=async()=> (u=u||import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.2.0/es6.js')).then(r=>r.default); - -export async function findShortestPath(graph,start,end){ - if(start===end) return 0; - if(!graph||typeof graph!=='object') return Infinity; - const own=Object.prototype.hasOwnProperty; - if(!own.call(graph,start)||!own.call(graph,end)) return Infinity; - const PriorityQueue=await loadQueue(); - const dist=new Map([[start,0]]); - const heap=new PriorityQueue({comparator:(a,b)=>a[1]-b[1]}); - heap.queue([start,0]); - while(heap.length){ - const [node,score]=heap.dequeue(); - if(score>dist.get(node)) continue; - if(node===end) return score; - const edges=graph[node]; - if(!edges) continue; - for(const [next,weight] of Object.entries(edges)){ - const total=score+weight; - if(total<(dist.get(next)??Infinity)){ - dist.set(next,total); - heap.queue([next,total]); - } - } - } - return Infinity; +let u +const o=()=>u||(u=import('https://cdn.skypack.dev/js-priority-queue').then(r=>r.default||r)) +async function findShortestPath(g,s,t){ +const PQ=await o() +if(s===t)return 0 +const d={},q=new PQ({comparator:(a,b)=>a[1]-b[1]}) +for(const k in g)d[k]=Infinity +d[s]=0 +q.queue([s,0]) +while(q.length){ +const[n,w]=q.dequeue() +if(w>d[n])continue +if(n===t)return w +for(const[nb,c]of Object.entries(g[n]||{})){ +const nw=w+c +if(nwd[k]=k===s?0:Infinity) + const q=new PriorityQueue({comparator:(a,b)=>a.w-b.w}) + q.queue({n:s,w:0}) + while(q.length){ + const{n,w}=q.dequeue() + if(v[n])continue + v[n]=1 + if(n===e)return w + const nbrs=g[n] + for(const x in nbrs){ + const nw=w+nbrs[x] + if(nw m.default); if (points.length < 3) return points; - const sorted = sortBy(uniqWith(points, (a, b) => a.x === b.x && a.y === b.y), ['x', 'y']); + const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']); if (sorted.length < 3) return sorted; const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); - const buildHull = arr => { + const buildHull = pts => { const hull = []; - for (const p of arr) { - while (hull.length > 1 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { + for (const p of pts) { + while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { hull.pop(); } hull.push(p); diff --git a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index 6c67fe8..d97329b 100644 --- a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,9 +1,9 @@ async function findConvexHull(points) { - const { sortBy, uniqWith } = await import('https://cdn.skypack.dev/lodash'); + const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js').then(m => m.default); if (points.length < 3) return points; - const sorted = sortBy(uniqWith(points, (a, b) => a.x === b.x && a.y === b.y), ['x', 'y']); + const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']); if (sorted.length < 3) return sorted; @@ -12,7 +12,7 @@ async function findConvexHull(points) { const buildHull = arr => { const hull = []; for (const p of arr) { - while (hull.length > 1 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { + while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { hull.pop(); } hull.push(p); @@ -21,6 +21,9 @@ async function findConvexHull(points) { return hull; }; - return [...buildHull(sorted), ...buildHull(sorted.slice().reverse())]; + const lower = buildHull(sorted); + const upper = buildHull([...sorted].reverse()); + + return [...lower, ...upper].reverse(); } export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js index a5f4e4d..5021050 100644 --- a/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js +++ b/tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js @@ -1,15 +1,15 @@ -async function findConvexHull(points) { - const { sortBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js'); +const findConvexHull = async (points) => { + const { sortBy, uniqWith } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js'); if (points.length < 3) return points; - const sorted = sortBy(uniqWith(points, isEqual), ['x', 'y']); + const sorted = sortBy(uniqWith(points, (a, b) => a.x === b.x && a.y === b.y), ['x', 'y']); if (sorted.length < 3) return sorted; const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); - const buildHull = (pts) => { + const buildHalf = (pts) => { const hull = []; for (const p of pts) { while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { @@ -21,9 +21,9 @@ async function findConvexHull(points) { return hull; }; - const lower = buildHull(sorted); - const upper = buildHull([...sorted].reverse()); + const lower = buildHalf(sorted); + const upper = buildHalf([...sorted].reverse()); return [...lower, ...upper].reverse(); -} +}; export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.4.js b/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.4.js deleted file mode 100644 index 1d1b8b2..0000000 --- a/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.4.js +++ /dev/null @@ -1,33 +0,0 @@ -async function findConvexHull(points) { - const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm'); - - const uniquePoints = _.uniqWith(points, _.isEqual); - - if (uniquePoints.length < 3) { - return uniquePoints; - } - - const sorted = _.sortBy(uniquePoints, ['x', 'y']); - - const crossProduct = (p1, p2, p3) => - (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); - - const buildHalfHull = (pts) => { - const hull = []; - for (const p of pts) { - while (hull.length >= 2 && crossProduct(hull.at(-2), hull.at(-1), p) <= 0) { - hull.pop(); - } - hull.push(p); - } - return hull; - }; - - const lower = buildHalfHull(sorted); - const upper = buildHalfHull([...sorted].reverse()); - - const hull = [...lower.slice(0, -1), ...upper.slice(0, -1)]; - - return [hull[0], ...hull.slice(1).reverse()]; -} -export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.7.js index e560260..1a2c810 100644 --- a/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.7.js +++ b/tests/2_convex_hull/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -1,34 +1,29 @@ async function findConvexHull(points) { - const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm'); + const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js'); - const uniqueSortedPoints = _.sortBy( - _.uniqBy(points, p => `${p.x}:${p.y}`), - ['x', 'y'] - ); + const sortedUniquePoints = _.uniqWith(_.sortBy(points, ['x', 'y']), _.isEqual); - if (uniqueSortedPoints.length < 3) { - return uniqueSortedPoints; + if (sortedUniquePoints.length < 3) { + return sortedUniquePoints; } const crossProduct = (p1, p2, p3) => (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); - const buildHalfHull = pts => { - const half = []; + const buildHalfHull = (pts) => { + const hull = []; for (const p of pts) { - while (half.length >= 2 && crossProduct(half.at(-2), half.at(-1), p) <= 0) { - half.pop(); + while (hull.length >= 2 && crossProduct(hull.at(-2), hull.at(-1), p) <= 0) { + hull.pop(); } - half.push(p); + hull.push(p); } - return half; + return hull; }; - const lower = buildHalfHull(uniqueSortedPoints); - const upper = buildHalfHull([...uniqueSortedPoints].reverse()); + const lowerHull = buildHalfHull(sortedUniquePoints); + const upperHull = buildHalfHull([...sortedUniquePoints].reverse()); - const ccwHull = lower.slice(0, -1).concat(upper.slice(0, -1)); - - return [ccwHull[0], ...ccwHull.slice(1).reverse()]; + return [...upperHull.slice(0, -1), ...lowerHull.slice(0, -1)]; } export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js b/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js deleted file mode 100644 index 4fafc71..0000000 --- a/tests/2_convex_hull/outputs/google_gemini-2.5-pro.js +++ /dev/null @@ -1,35 +0,0 @@ -const findConvexHull = async (points) => { - const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm'); - - const sortedPoints = _.sortBy(points, ['x', 'y']); - const uniquePoints = _.uniqWith(sortedPoints, _.isEqual); - - if (uniquePoints.length < 3) { - return uniquePoints; - } - - const crossProduct = (p1, p2, p3) => - (p2.x - p1.x) * (p3.y - p1.y) - (p2.y - p1.y) * (p3.x - p1.x); - - const lower = []; - for (const p of uniquePoints) { - while (lower.length >= 2 && crossProduct(lower.at(-2), lower.at(-1), p) <= 0) { - lower.pop(); - } - lower.push(p); - } - - const upper = []; - for (let i = uniquePoints.length - 1; i >= 0; i--) { - const p = uniquePoints[i]; - while (upper.length >= 2 && crossProduct(upper.at(-2), upper.at(-1), p) <= 0) { - upper.pop(); - } - upper.push(p); - } - - const hull = [...lower.slice(0, -1), ...upper.slice(0, -1)]; - - return hull.reverse(); -}; -export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/openai_gpt-5-codex.js b/tests/2_convex_hull/outputs/openai_gpt-5-codex.js index a65489b..7d1c3d4 100644 --- a/tests/2_convex_hull/outputs/openai_gpt-5-codex.js +++ b/tests/2_convex_hull/outputs/openai_gpt-5-codex.js @@ -1,23 +1,19 @@ -const lod=import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js'); - -export async function findConvexHull(input){ - if(!Array.isArray(input)) return []; - const {uniqBy:uniq,sortBy:sort}=await lod; - const pts=sort(uniq(input.filter(p=>p&&Number.isFinite(p.x)&&Number.isFinite(p.y)).map(p=>({x:+p.x,y:+p.y})),p=>`${p.x}:${p.y}`),['x','y']); - if(pts.length<2) return pts; - const area=(a,b,c)=>(b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x); - const walk=list=>{ - const res=[]; - for(const p of list){ - while(res.length>1&&area(res[res.length-2],res[res.length-1],p)<=0)res.pop(); - res.push(p); - } - return res; - }; - const low=walk(pts); - const up=walk(pts.slice().reverse()); - const hull=low.slice(0,-1).concat(up.slice(0,-1)); - const out=hull.length?hull:pts.slice(0,2); - return out.length<3?out:out.reverse(); +async function findConvexHull(points){ + const {default:_}=await import('https://cdn.skypack.dev/lodash-es'); + const pts=_.uniqWith(_.sortBy(points,['x','y']),(a,b)=>a.x===b.x&&a.y===b.y); + if(pts.length<3) return pts.slice(); + const c=(o,a,b)=>(a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x); + const l=[],u=[]; + for(const p of pts){ + while(l.length>1&&c(l.at(-2),l.at(-1),p)<=0)l.pop(); + l.push(p); + } + for(let i=pts.length;i--;){ + const p=pts[i]; + while(u.length>1&&c(u.at(-2),u.at(-1),p)<=0)u.pop(); + u.push(p); + } + l.pop();u.pop(); + return [...l,...u].reverse(); } export default findConvexHull; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/openrouter_polaris-alpha.js b/tests/2_convex_hull/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..2e5473c --- /dev/null +++ b/tests/2_convex_hull/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,29 @@ +async function findConvexHull(points) { + if (!Array.isArray(points) || points.length < 3) return points || []; + const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.default.min.js'); + const ps = _.uniqWith(points, (a, b) => a.x === b.x && a.y === b.y); + if (ps.length < 3) return ps; + const pts = _.sortBy(ps, ['x', 'y']); + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + const lower = []; + for (let p of pts) { + for (; lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0;) lower.pop(); + lower.push(p); + } + const upper = []; + for (let i = pts.length - 1; i >= 0; i--) { + const p = pts[i]; + for (; upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0;) upper.pop(); + upper.push(p); + } + const hull = lower.slice(0, -1).concat(upper.slice(0, -1)); + if (hull.length <= 2) return hull; + let area = 0; + for (let i = 0; i < hull.length; i++) { + const j = (i + 1) % hull.length; + area += hull[i].x * hull[j].y - hull[j].x * hull[i].y; + } + if (area > 0) hull.reverse(); + return hull; +} +export default findConvexHull; \ No newline at end of file diff --git a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js index 3dbf913..a325e10 100644 --- a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js +++ b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -2,7 +2,6 @@ const findLISLength = async (arr) => { if (!arr?.length) return 0; const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); - const tails = []; for (const num of arr) { @@ -12,5 +11,4 @@ const findLISLength = async (arr) => { return tails.length; }; - -export default findLISLength; +export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js index c9c767d..b3d6589 100644 --- a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js +++ b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -1,8 +1,8 @@ -const findLISLength = async (arr) => { - if (!arr?.length) return 0; - +async function findLISLength(arr) { const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); + if (!arr?.length) return 0; + const tails = []; for (const num of arr) { @@ -11,5 +11,5 @@ const findLISLength = async (arr) => { } return tails.length; -}; +} export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js index cdc477e..fd86b86 100644 --- a/tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js +++ b/tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js @@ -1,15 +1,15 @@ -const findLISLength = async (nums) => { - const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); - +async function findLISLength(nums) { if (!nums?.length) return 0; + const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array'); + const tails = []; for (const num of nums) { - const idx = bisectLeft(tails, num); - tails[idx] = num; + const pos = bisectLeft(tails, num); + tails[pos] = num; } return tails.length; -}; +} export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js b/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js deleted file mode 100644 index 0bc6555..0000000 --- a/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js +++ /dev/null @@ -1,14 +0,0 @@ -const findLISLength = async (nums) => { - if (!nums?.length) return 0; - - const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm'); - - const tails = []; - - for (const num of nums) { - tails[bisectLeft(tails, num)] = num; - } - - return tails.length; -}; -export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js index 47b08b3..44a9648 100644 --- a/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js +++ b/tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -1,13 +1,15 @@ const findLISLength = async (nums) => { - if (!nums?.length) return 0; - - const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm'); - const tails = []; - - for (const num of nums) { - tails[bisectLeft(tails, num)] = num; + if (!nums?.length) { + return 0; } + const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array@3"); + + const tails = nums.reduce((sub, num) => { + sub[bisectLeft(sub, num)] = num; + return sub; + }, []); + return tails.length; }; export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/google_gemini-2.5-pro.js b/tests/3_lis/outputs/google_gemini-2.5-pro.js deleted file mode 100644 index 88c9ab0..0000000 --- a/tests/3_lis/outputs/google_gemini-2.5-pro.js +++ /dev/null @@ -1,13 +0,0 @@ -const findLISLength = async (nums) => { - if (!Array.isArray(nums) || !nums.length) return 0; - - const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array"); - const tails = []; - - for (const num of nums) { - tails[bisectLeft(tails, num)] = num; - } - - return tails.length; -}; -export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/openai_gpt-5-codex.js b/tests/3_lis/outputs/openai_gpt-5-codex.js index 81fc153..65ed793 100644 --- a/tests/3_lis/outputs/openai_gpt-5-codex.js +++ b/tests/3_lis/outputs/openai_gpt-5-codex.js @@ -1,14 +1,14 @@ -const loadBisectLeft=(()=>{let cache;return()=>cache||(cache=import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm').then(({bisectLeft})=>bisectLeft));})(); -export async function findLISLength(nums){ - if(!Array.isArray(nums)) throw new TypeError('Expected an array'); - if(!nums.length) return 0; - const bisectLeft=await loadBisectLeft(); - const tails=[]; - for(const value of nums){ - if(!Number.isFinite(value)) throw new TypeError('Array must contain only finite numbers'); - const index=bisectLeft(tails,value,0,tails.length); - tails[index]=value; - } - return tails.length; +const findLISLength=async a=>{ + if(!Array.isArray(a)) throw new TypeError('Expected an array') + const {bisectLeft:b}=await (findLISLength.m??=import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')) + const t=[] + for(const v of a){ + if(!Number.isFinite(v)) throw new TypeError('Array values must be finite numbers') + const i=b(t,v) + if(i===t.length) t.push(v) + else t[i]=v + } + return t.length } +window.findLISLength=findLISLength export default findLISLength; \ No newline at end of file diff --git a/tests/3_lis/outputs/openrouter_polaris-alpha.js b/tests/3_lis/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..1a52638 --- /dev/null +++ b/tests/3_lis/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,12 @@ +async function findLISLength(a){ + if(!a||!a.length)return 0 + const{bisectLeft}=await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm') + const t=[] + for(const x of a){ + const i=bisectLeft(t,x) + if(i===t.length)t.push(x) + else t[i]=x + } + return t.length +} +export default findLISLength; \ No newline at end of file diff --git a/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.4.js b/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.4.js deleted file mode 100644 index e551fc7..0000000 --- a/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.4.js +++ /dev/null @@ -1,5 +0,0 @@ -const calculateDeterminant = async (matrix) => { - const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@13.0.0/es/index.js'); - return det(matrix); -}; -export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.7.js index e551fc7..c98689d 100644 --- a/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.7.js +++ b/tests/4_determinant/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -1,5 +1,5 @@ -const calculateDeterminant = async (matrix) => { - const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@13.0.0/es/index.js'); - return det(matrix); +const calculateDeterminant = async m => { + const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@13.0.0/es/math.mjs'); + return det(m); }; export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/google_gemini-2.5-pro.js b/tests/4_determinant/outputs/google_gemini-2.5-pro.js deleted file mode 100644 index bf16fe9..0000000 --- a/tests/4_determinant/outputs/google_gemini-2.5-pro.js +++ /dev/null @@ -1,5 +0,0 @@ -const calculateDeterminant = async (matrix) => { - const { det } = await import('https://esm.sh/mathjs'); - return det(matrix); -}; -export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/openai_gpt-5-codex.js b/tests/4_determinant/outputs/openai_gpt-5-codex.js index 68b2561..ff7c9a6 100644 --- a/tests/4_determinant/outputs/openai_gpt-5-codex.js +++ b/tests/4_determinant/outputs/openai_gpt-5-codex.js @@ -1,7 +1,5 @@ -const src='https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm' -export const calculateDeterminant=async m=>{ - if(!Array.isArray(m)||!m.length||m.some(r=>!Array.isArray(r)||r.length!==m.length))throw new TypeError('Matrix must be square') - const{det}=await import(src) - return det(m) +async function calculateDeterminant(m){ + const {det}=await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/dist/esm/math.js') + return det(m) } export default calculateDeterminant; \ No newline at end of file diff --git a/tests/4_determinant/outputs/openrouter_polaris-alpha.js b/tests/4_determinant/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..3432fbe --- /dev/null +++ b/tests/4_determinant/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,7 @@ +async function calculateDeterminant(m){ + if(!Array.isArray(m)||!m.length||!m.every(r=>Array.isArray(r)&&r.length===m.length))throw new Error('Input must be an n x n matrix'); + const {create,all,det}=await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm'); + const math=create(all); + return math.det(m); +} +export default calculateDeterminant; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js new file mode 100644 index 0000000..0476b36 --- /dev/null +++ b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -0,0 +1,5 @@ +async function parseMarkdown(md) { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm'); + return marked.parse(md); +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js new file mode 100644 index 0000000..0476b36 --- /dev/null +++ b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -0,0 +1,5 @@ +async function parseMarkdown(md) { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm'); + return marked.parse(md); +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5.js b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5.js new file mode 100644 index 0000000..0476b36 --- /dev/null +++ b/tests/5_markdown_parser/outputs/anthropic_claude-sonnet-4.5.js @@ -0,0 +1,5 @@ +async function parseMarkdown(md) { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@11.1.1/+esm'); + return marked.parse(md); +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/5_markdown_parser/outputs/google_gemini-2.5-pro TEMP_0.7.js new file mode 100644 index 0000000..53fd2f4 --- /dev/null +++ b/tests/5_markdown_parser/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -0,0 +1,5 @@ +const parseMarkdown = async (md) => { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked@5/+esm'); + return marked.parse(md); +}; +export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openai_gpt-5-codex.js b/tests/5_markdown_parser/outputs/openai_gpt-5-codex.js new file mode 100644 index 0000000..6b5f9f9 --- /dev/null +++ b/tests/5_markdown_parser/outputs/openai_gpt-5-codex.js @@ -0,0 +1,15 @@ +let md,pd +const getMd=()=>md||(md=import('https://cdn.jsdelivr.net/npm/marked@12.0.2/+esm').then(x=>{ + let m=x.marked||x.default + m.setOptions?.({gfm:true,breaks:true,smartypants:true}) + return s=>m.parse?m.parse(s):m(s) +})) +const getPurify=()=>pd||(pd=import('https://esm.sh/dompurify@3?target=es2020').then(x=>{ + let d=x.default||x.DOMPurify||x + return typeof d.sanitize=='function'?d:d(window) +})) +async function parseMarkdown(s){ + let [render,pur]=await Promise.all([getMd(),getPurify()]) + return pur.sanitize(render(s)) +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openrouter_polaris-alpha.js b/tests/5_markdown_parser/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..03cdb80 --- /dev/null +++ b/tests/5_markdown_parser/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,11 @@ +async function parseMarkdown(markdown) { + const {marked} = await import('https://cdn.jsdelivr.net/npm/marked@12.0.2/lib/marked.esm.js') + marked.setOptions({ + gfm:true, + breaks:false, + headerIds:true, + mangle:false + }) + return marked.parse(String(markdown ?? '')) +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js new file mode 100644 index 0000000..b11ec62 --- /dev/null +++ b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -0,0 +1,26 @@ +async function processCSV(csv, config) { + const { parse } = await import('https://cdn.skypack.dev/papaparse@5.4.1'); + + const { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op } = config; + const { data } = parse(csv, { header: true, skipEmptyLines: true }); + + const filtered = data.filter(r => r[fc] == fv); + const grouped = filtered.reduce((acc, row) => { + const key = row[gb]; + if (!acc[key]) acc[key] = []; + acc[key].push(row); + return acc; + }, {}); + + return Object.entries(grouped).map(([key, rows]) => { + const vals = rows.map(r => parseFloat(r[ac]) || 0); + const result = op === 'sum' + ? vals.reduce((a, b) => a + b, 0) + : op === 'avg' + ? vals.reduce((a, b) => a + b, 0) / vals.length + : vals.length; + + return { [gb]: key, result }; + }); +} +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js new file mode 100644 index 0000000..750c4bf --- /dev/null +++ b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -0,0 +1,30 @@ +const processCSV = async (csv, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => { + const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'); + + const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true }); + + const filtered = data.filter(row => row[filterColumn] == filterValue); + + const grouped = filtered.reduce((acc, row) => { + const key = row[groupBy]; + if (!acc[key]) acc[key] = []; + acc[key].push(row); + return acc; + }, {}); + + return Object.entries(grouped).map(([key, rows]) => { + let result; + + if (operation === 'count') { + result = rows.length; + } else { + const values = rows.map(r => parseFloat(r[aggregateColumn]) || 0); + result = operation === 'sum' + ? values.reduce((a, b) => a + b, 0) + : values.reduce((a, b) => a + b, 0) / values.length; + } + + return { [groupBy]: key, [operation]: result }; + }); +}; +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5.js b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5.js new file mode 100644 index 0000000..4565062 --- /dev/null +++ b/tests/6_csv_processor/outputs/anthropic_claude-sonnet-4.5.js @@ -0,0 +1,30 @@ +async function processCSV(csvString, config) { + const { parse } = await import('https://cdn.skypack.dev/papaparse@5.4.1'); + + const { filterColumn: fc, filterValue: fv, groupBy: gb, aggregateColumn: ac, operation: op } = config; + + const { data } = parse(csvString, { header: true, skipEmptyLines: true }); + + const filtered = data.filter(row => row[fc] == fv); + + const grouped = filtered.reduce((acc, row) => { + const key = row[gb]; + if (!acc[key]) acc[key] = []; + acc[key].push(row); + return acc; + }, {}); + + return Object.entries(grouped).map(([key, rows]) => { + let result; + if (op === 'count') { + result = rows.length; + } else { + const values = rows.map(r => parseFloat(r[ac]) || 0); + result = op === 'sum' + ? values.reduce((a, b) => a + b, 0) + : values.reduce((a, b) => a + b, 0) / values.length; + } + return { [gb]: key, result }; + }); +} +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/6_csv_processor/outputs/google_gemini-2.5-pro TEMP_0.7.js new file mode 100644 index 0000000..c4ecd74 --- /dev/null +++ b/tests/6_csv_processor/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -0,0 +1,40 @@ +const processCSV = async (csvString, { + filterColumn, + filterValue, + groupBy, + aggregateColumn, + operation +}) => { + const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'); + + const aggregations = { + sum: g => g.s, + count: g => g.c, + avg: g => g.c ? g.s / g.c : 0, + }; + + const groupedData = Papa.parse(csvString, { + header: true, + skipEmptyLines: true, + dynamicTyping: true, + }).data + .filter(row => row[filterColumn] === filterValue) + .reduce((acc, row) => { + const key = row[groupBy]; + const val = row[aggregateColumn]; + + acc[key] = acc[key] || { s: 0, c: 0 }; + if (typeof val === 'number' && !isNaN(val)) { + acc[key].s += val; + } + acc[key].c++; + + return acc; + }, {}); + + return Object.entries(groupedData).map(([key, group]) => ({ + [groupBy]: /^-?\d+(\.\d+)?$/.test(key) ? Number(key) : key, + [operation]: aggregations[operation](group), + })); +}; +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openai_gpt-5-codex.js b/tests/6_csv_processor/outputs/openai_gpt-5-codex.js new file mode 100644 index 0000000..deeda75 --- /dev/null +++ b/tests/6_csv_processor/outputs/openai_gpt-5-codex.js @@ -0,0 +1,20 @@ +let cache; +async function processCSV(csv,cfg){ + const {csvParse,rollups}=await (cache??=import('https://cdn.jsdelivr.net/npm/d3@7/+esm')); + const {filterColumn,filterValue,groupBy,aggregateColumn,operation}=cfg; + if(!['sum','avg','count'].includes(operation))throw new Error('Unsupported operation'); + if(!csv||!filterColumn||!groupBy)throw new Error('Missing essentials'); + if(operation!=='count'&&!aggregateColumn)throw new Error('Missing aggregateColumn'); + const rows=csvParse(csv).filter(r=>r[filterColumn]==filterValue); + if(!rows.length)return[]; + const fn=operation==='count'?v=>v.length:v=>{ + let s=0,n=0; + for(const row of v){ + const val=+row[aggregateColumn]; + if(!Number.isNaN(val)){s+=val;n++;} + } + return operation==='sum'?s:n?s/n:0; + }; + return rollups(rows,fn,r=>r[groupBy]).map(([k,v])=>({[groupBy]:k,[operation]:v})); +} +export default processCSV; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openrouter_polaris-alpha.js b/tests/6_csv_processor/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..547c963 --- /dev/null +++ b/tests/6_csv_processor/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,30 @@ +async function processCSV(csv, cfg) { + const {filterColumn,filterValue,groupBy,aggregateColumn,operation} = cfg + if(!csv||!filterColumn||!groupBy||!operation) throw new Error('Invalid configuration') + const [{parse},{default:lodash}] = await Promise.all([ + import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'), + import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm') + ]) + const {data,errors} = parse(csv,{header:true,skipEmptyLines:true,dynamicTyping:true}) + if(errors?.length) throw new Error('CSV parse error') + const rows = data.filter(r=>r[filterColumn]===filterValue) + if(!rows.length) return [] + const grouped = lodash.groupBy(rows,r=>r[groupBy]) + const out = [] + for(const k in grouped){ + const g = grouped[k] + let v + if(operation==='count') v = g.length + else{ + const nums = g.map(r=>Number(r[aggregateColumn])).filter(n=>Number.isFinite(n)) + if(!nums.length) { v = operation==='sum'?0:null } + else{ + const s = nums.reduce((a,b)=>a+b,0) + v = operation==='sum'?s:s/nums.length + } + } + out.push({[groupBy]:k,result:v}) + } + return out +} +export default processCSV; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js new file mode 100644 index 0000000..e08274f --- /dev/null +++ b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -0,0 +1,78 @@ +const findAvailableSlots = async (cal1, cal2, constraints) => { + const { default: dayjs } = await import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/+esm'); + const [{ default: utc }, { default: customParseFormat }, { default: isBetween }] = await Promise.all([ + import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/utc.js'), + import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/customParseFormat.js'), + import('https://cdn.jsdelivr.net/npm/dayjs@1.11.10/plugin/isBetween.js') + ]); + + dayjs.extend(utc); + dayjs.extend(customParseFormat); + dayjs.extend(isBetween); + + const { durationMinutes, searchRange, workHours } = constraints; + const duration = durationMinutes; + + const mergedBusy = [...cal1, ...cal2] + .map(({ start, end }) => ({ start: dayjs(start), end: dayjs(end) })) + .sort((a, b) => a.start - b.start) + .reduce((acc, curr) => { + if (!acc.length) return [curr]; + const last = acc[acc.length - 1]; + if (curr.start <= last.end) { + last.end = dayjs.max(last.end, curr.end); + return acc; + } + return [...acc, curr]; + }, []); + + const searchStart = dayjs(searchRange.start); + const searchEnd = dayjs(searchRange.end); + const [workStart, workEnd] = [workHours.start, workHours.end]; + + const slots = []; + let current = searchStart; + + while (current < searchEnd) { + const dayStart = dayjs(`${current.format('YYYY-MM-DD')}T${workStart}`); + const dayEnd = dayjs(`${current.format('YYYY-MM-DD')}T${workEnd}`); + + const workStart_ = dayjs.max(current, dayStart); + const workEnd_ = dayjs.min(searchEnd, dayEnd); + + if (workStart_ < workEnd_) { + const dayBusy = mergedBusy.filter(b => + b.start < workEnd_ && b.end > workStart_ + ); + + let pointer = workStart_; + + for (const busy of dayBusy) { + const gapEnd = dayjs.min(busy.start, workEnd_); + + while (pointer.add(duration, 'minute') <= gapEnd) { + slots.push({ + start: pointer.toISOString(), + end: pointer.add(duration, 'minute').toISOString() + }); + pointer = pointer.add(duration, 'minute'); + } + + pointer = dayjs.max(pointer, busy.end); + } + + while (pointer.add(duration, 'minute') <= workEnd_) { + slots.push({ + start: pointer.toISOString(), + end: pointer.add(duration, 'minute').toISOString() + }); + pointer = pointer.add(duration, 'minute'); + } + } + + current = current.add(1, 'day').startOf('day'); + } + + return slots; +}; +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js new file mode 100644 index 0000000..a1b8699 --- /dev/null +++ b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -0,0 +1,93 @@ +const findAvailableSlots = async (cal1, cal2, constraints) => { + const { default: dayjs } = await import('https://cdn.skypack.dev/dayjs@1.11.10'); + const { default: utc } = await import('https://cdn.skypack.dev/dayjs@1.11.10/plugin/utc'); + const { default: customParseFormat } = await import('https://cdn.skypack.dev/dayjs@1.11.10/plugin/customParseFormat'); + + dayjs.extend(utc); + dayjs.extend(customParseFormat); + + const { durationMinutes, searchRange, workHours } = constraints; + const duration = durationMinutes * 60000; + + const merged = [...cal1, ...cal2] + .map(({ start, end }) => ({ start: new Date(start).getTime(), end: new Date(end).getTime() })) + .sort((a, b) => a.start - b.start); + + const busy = merged.reduce((acc, slot) => { + if (!acc.length) return [slot]; + const last = acc[acc.length - 1]; + if (slot.start <= last.end) { + last.end = Math.max(last.end, slot.end); + return acc; + } + acc.push(slot); + return acc; + }, []); + + const rangeStart = new Date(searchRange.start).getTime(); + const rangeEnd = new Date(searchRange.end).getTime(); + const [whStart, whEnd] = [workHours.start, workHours.end]; + + const isWithinWorkHours = (ts) => { + const d = dayjs(ts); + const time = d.format('HH:mm'); + return time >= whStart && time <= whEnd; + }; + + const getWorkDayBounds = (ts) => { + const d = dayjs(ts); + const [h1, m1] = whStart.split(':').map(Number); + const [h2, m2] = whEnd.split(':').map(Number); + return { + start: d.hour(h1).minute(m1).second(0).millisecond(0).valueOf(), + end: d.hour(h2).minute(m2).second(0).millisecond(0).valueOf() + }; + }; + + const slots = []; + let current = rangeStart; + + for (let ts = rangeStart; ts < rangeEnd; ts += 86400000) { + const { start: dayStart, end: dayEnd } = getWorkDayBounds(ts); + current = Math.max(current, dayStart); + + busy.forEach(({ start: bStart, end: bEnd }) => { + if (bStart > current && bStart <= dayEnd) { + let slotStart = current; + while (slotStart + duration <= Math.min(bStart, dayEnd)) { + const slotEnd = slotStart + duration; + if (isWithinWorkHours(slotStart) && isWithinWorkHours(slotEnd)) { + slots.push({ + start: new Date(slotStart).toISOString(), + end: new Date(slotEnd).toISOString() + }); + } + slotStart = slotEnd; + } + current = Math.max(current, bEnd); + } + if (bEnd > current && bEnd <= dayEnd) { + current = Math.max(current, bEnd); + } + }); + + if (current < dayEnd) { + let slotStart = current; + while (slotStart + duration <= dayEnd) { + const slotEnd = slotStart + duration; + if (isWithinWorkHours(slotStart) && isWithinWorkHours(slotEnd)) { + slots.push({ + start: new Date(slotStart).toISOString(), + end: new Date(slotEnd).toISOString() + }); + } + slotStart = slotEnd; + } + } + + current = dayStart + 86400000; + } + + return slots; +}; +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5.js b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5.js new file mode 100644 index 0000000..0ed9bab --- /dev/null +++ b/tests/7_scheduler/outputs/anthropic_claude-sonnet-4.5.js @@ -0,0 +1,74 @@ +const findAvailableSlots = async (cal1, cal2, constraints) => { + const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon'); + + const { durationMinutes: dur, searchRange: sr, workHours: wh } = constraints; + const [srStart, srEnd] = [DateTime.fromISO(sr.start), DateTime.fromISO(sr.end)]; + const [whStart, whEnd] = wh.start.split(':').map(Number); + + const toInterval = ({ start, end }) => + Interval.fromDateTimes(DateTime.fromISO(start), DateTime.fromISO(end)); + + const busySlots = [...cal1, ...cal2] + .map(toInterval) + .sort((a, b) => a.start - b.start); + + const merged = busySlots.reduce((acc, curr) => { + if (!acc.length) return [curr]; + const last = acc[acc.length - 1]; + return last.overlaps(curr) || last.abutsStart(curr) + ? [...acc.slice(0, -1), last.union(curr)] + : [...acc, curr]; + }, []); + + const isWorkHours = dt => { + const h = dt.hour, m = dt.minute; + const mins = h * 60 + m; + const whStartMins = whStart[0] * 60 + whStart[1]; + const whEndMins = whEnd[0] * 60 + whEnd[1]; + return mins >= whStartMins && mins < whEndMins; + }; + + const slots = []; + let curr = srStart; + + while (curr < srEnd) { + const dayStart = curr.set({ hour: whStart[0], minute: whStart[1], second: 0 }); + const dayEnd = curr.set({ hour: whEnd[0], minute: whEnd[1], second: 0 }); + + if (dayStart >= srEnd) break; + + const effectiveStart = dayStart > srStart ? dayStart : srStart; + const effectiveEnd = dayEnd < srEnd ? dayEnd : srEnd; + + let pointer = effectiveStart; + + while (pointer.plus({ minutes: dur }) <= effectiveEnd) { + const slotEnd = pointer.plus({ minutes: dur }); + const slotInterval = Interval.fromDateTimes(pointer, slotEnd); + + const isFree = !merged.some(busy => + busy.overlaps(slotInterval) || slotInterval.overlaps(busy) + ); + + if (isFree && isWorkHours(pointer) && isWorkHours(slotEnd.minus({ minutes: 1 }))) { + slots.push({ + start: pointer.toISO(), + end: slotEnd.toISO() + }); + pointer = slotEnd; + } else { + const nextBusy = merged.find(busy => busy.start > pointer); + if (nextBusy && nextBusy.start < effectiveEnd) { + pointer = nextBusy.end > pointer ? nextBusy.end : pointer.plus({ minutes: 1 }); + } else { + pointer = pointer.plus({ minutes: 1 }); + } + } + } + + curr = curr.plus({ days: 1 }).startOf('day'); + } + + return slots; +}; +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/7_scheduler/outputs/google_gemini-2.5-pro TEMP_0.7.js new file mode 100644 index 0000000..4cab5d6 --- /dev/null +++ b/tests/7_scheduler/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -0,0 +1,56 @@ +async function findAvailableSlots( + calendar1, + calendar2, + { durationMinutes: dur, searchRange: sr, workHours: wh } +) { + const dayjs = (await import('https://cdn.skypack.dev/dayjs')).default; + const utc = (await import('https://cdn.skypack.dev/dayjs/plugin/utc')).default; + dayjs.extend(utc); + + const d = (s) => dayjs.utc(s); + const rangeStart = d(sr.start); + const rangeEnd = d(sr.end); + const [whsH, whsM] = wh.start.split(':'); + const [wheH, wheM] = wh.end.split(':'); + + const busySlots = [...calendar1, ...calendar2].map(({ start, end }) => ({ + start: d(start), + end: d(end), + })); + + for (let day = rangeStart.clone().startOf('d'); day.isBefore(rangeEnd); day = day.add(1, 'd')) { + busySlots.push({ start: day.startOf('d'), end: day.hour(whsH).minute(whsM) }); + busySlots.push({ start: day.hour(wheH).minute(wheM), end: day.endOf('d') }); + } + + const merged = busySlots + .filter(({ start, end }) => start.isBefore(end)) + .sort((a, b) => a.start - b.start) + .reduce((acc, cur) => { + const last = acc.at(-1); + if (!last || cur.start.isAfter(last.end)) { + acc.push(cur); + } else if (cur.end.isAfter(last.end)) { + last.end = cur.end; + } + return acc; + }, []); + + const available = []; + let cursor = rangeStart; + + [...merged, { start: rangeEnd, end: rangeEnd }].forEach((busy) => { + const gapEnd = busy.start; + for (let slotStart = cursor; !slotStart.add(dur, 'm').isAfter(gapEnd); slotStart = slotStart.add(dur, 'm')) { + const slotEnd = slotStart.add(dur, 'm'); + available.push({ + start: slotStart.toISOString(), + end: slotEnd.toISOString(), + }); + } + cursor = cursor.isAfter(busy.end) ? cursor : busy.end; + }); + + return available; +} +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/openai_gpt-5-codex.js b/tests/7_scheduler/outputs/openai_gpt-5-codex.js new file mode 100644 index 0000000..7c8a3c6 --- /dev/null +++ b/tests/7_scheduler/outputs/openai_gpt-5-codex.js @@ -0,0 +1,55 @@ +let df +async function findAvailableSlots(a,b,c){ + df??=await import('https://cdn.jsdelivr.net/npm/date-fns@3.6.0/+esm') + const {parseISO:pi,formatISO:fi,eachDayOfInterval:ed,set:st}=df + const sr=pi(c.searchRange.start),er=pi(c.searchRange.end),srT=+sr,erT=+er + const [hs,ms]=c.workHours.start.split(':').map(Number) + const [he,me]=c.workHours.end.split(':').map(Number) + const step=c.durationMinutes*6e4 + const norm=u=>{ + const arr=u.map(v=>({s:+pi(v.start),e:+pi(v.end)})).filter(v=>v.e>srT&&v.s({s:Math.max(v.s,srT),e:Math.min(v.e,erT)})).filter(v=>v.e>v.s).sort((x,y)=>x.s-y.s) + const out=[] + arr.forEach(v=>{ + const w=out[out.length-1] + if(!w||v.s>w.e)out.push({s:v.s,e:v.e}) + else w.e=Math.max(w.e,v.e) + }) + return out + } + const free=u=>{ + const busy=norm(u),days=ed({start:sr,end:er}),out=[] + let i=0 + for(const day of days){ + const d0=Math.max(+st(day,{hours:hs,minutes:ms,seconds:0,milliseconds:0}),srT) + const d1=Math.min(+st(day,{hours:he,minutes:me,seconds:0,milliseconds:0}),erT) + if(d0>=d1)continue + while(icur)out.push({s:cur,e:Math.min(busy[j].s,d1)}) + cur=Math.max(cur,busy[j].e) + if(cur>=d1)break + j++ + } + if(cur=step){ + const k=Math.floor((e-s)/step) + for(let n=0;ny[j].e?j++:(i++,j++) + } + return res +} +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/openrouter_polaris-alpha.js b/tests/7_scheduler/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..f91b637 --- /dev/null +++ b/tests/7_scheduler/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,115 @@ +async function findAvailableSlots(calA, calB, c) { + const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon').then(m => m); + const d = c.durationMinutes; + const z = DateTime.utc().zoneName; + const parseIso = s => DateTime.fromISO(s, { zone: 'utc' }); + const parseHm = (hm, base) => { + const [H, M] = hm.split(':').map(Number); + return base.set({ hour: H, minute: M, second: 0, millisecond: 0 }); + }; + const toIso = dt => dt.toUTC().toISO(); + + const rStart = parseIso(c.searchRange.start); + const rEnd = parseIso(c.searchRange.end); + + const dayRange = []; + for (let d0 = rStart.startOf('day'); d0 < rEnd; d0 = d0.plus({ days: 1 })) { + const ws = parseHm(c.workHours.start, d0); + const we = parseHm(c.workHours.end, d0); + const s = ws < rStart ? rStart : ws; + const e = we > rEnd ? rEnd : we; + if (e > s) dayRange.push(Interval.fromDateTimes(s, e)); + } + + const normalizeBusy = cal => + cal + .map(({ start, end }) => { + const s = parseIso(start), e = parseIso(end); + return e > s ? Interval.fromDateTimes(s, e) : null; + }) + .filter(Boolean) + .sort((a, b) => a.start - b.start); + + const mergeBusy = busy => { + const m = []; + for (const i of busy) { + const last = m[m.length - 1]; + if (!last || i.start > last.end) m.push(i); + else if (i.end > last.end) last.end = i.end; + } + return m; + }; + + const intersectWithRange = (busy, ranges) => { + const res = []; + let j = 0; + for (const r of ranges) { + while (j < busy.length && busy[j].end <= r.start) j++; + let k = j; + while (k < busy.length && busy[k].start < r.end) { + const s = busy[k].start < r.start ? r.start : busy[k].start; + const e = busy[k].end > r.end ? r.end : busy[k].end; + if (e > s) res.push(Interval.fromDateTimes(s, e)); + k++; + } + } + return mergeBusy(res); + }; + + const invertBusy = (busy, ranges) => { + const free = []; + for (const r of ranges) { + let cur = r.start; + for (const b of busy) { + if (b.end <= r.start || b.start >= r.end) continue; + if (b.start > cur) free.push(Interval.fromDateTimes(cur, b.start)); + if (b.end > cur) cur = b.end; + if (cur >= r.end) break; + } + if (cur < r.end) free.push(Interval.fromDateTimes(cur, r.end)); + } + return free; + }; + + const intersectFree = (fa, fb) => { + const res = []; + let i = 0, j = 0; + while (i < fa.length && j < fb.length) { + const a = fa[i], b = fb[j]; + const s = a.start > b.start ? a.start : b.start; + const e = a.end < b.end ? a.end : b.end; + if (e > s) res.push(Interval.fromDateTimes(s, e)); + if (a.end < b.end) i++; + else j++; + } + return res; + }; + + const filterByDuration = (slots, minutes) => { + const out = []; + const dur = { minutes }; + for (const s of slots) { + let cur = s.start; + while (cur.plus(dur) <= s.end) { + const end = cur.plus(dur); + out.push({ start: toIso(cur), end: toIso(end) }); + cur = end; + } + } + return out; + }; + + const busyA = mergeBusy(normalizeBusy(calA)); + const busyB = mergeBusy(normalizeBusy(calB)); + + const busyAIn = intersectWithRange(busyA, dayRange); + const busyBIn = intersectWithRange(busyB, dayRange); + + const freeA = invertBusy(busyAIn, dayRange); + const freeB = invertBusy(busyBIn, dayRange); + + const mutualFree = intersectFree(freeA, freeB); + + return filterByDuration(mutualFree, d); +} +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js new file mode 100644 index 0000000..f1866da --- /dev/null +++ b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js @@ -0,0 +1,18 @@ +const validateJSON = async (data, schema) => { + const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/dist/2020.min.js'); + + const ajv = new Ajv({ allErrors: true, strict: false }); + const validate = ajv.compile(schema); + const valid = validate(data); + + return { + valid, + errors: valid ? [] : validate.errors.map(e => ({ + path: e.instancePath || '/', + message: e.message, + keyword: e.keyword, + params: e.params + })) + }; +}; +export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js new file mode 100644 index 0000000..bc8bb7e --- /dev/null +++ b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js @@ -0,0 +1,16 @@ +const validateJSON = async (data, schema) => { + const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/2020.min.js'); + const ajv = new Ajv({ allErrors: true, verbose: true }); + const validate = ajv.compile(schema); + const valid = validate(data); + return { + valid, + errors: valid ? [] : validate.errors.map(e => ({ + path: e.instancePath || '/', + message: e.message, + keyword: e.keyword, + params: e.params + })) + }; +}; +export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5.js b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5.js new file mode 100644 index 0000000..4c929d0 --- /dev/null +++ b/tests/8_json_validator/outputs/anthropic_claude-sonnet-4.5.js @@ -0,0 +1,15 @@ +const validateJSON = async (data, schema) => { + const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.bundle.js'); + + const ajv = new Ajv({ allErrors: true }); + const validate = ajv.compile(schema); + const valid = validate(data); + + return { + valid, + errors: valid ? [] : validate.errors.map(e => + `${e.instancePath || 'root'} ${e.message}` + ) + }; +}; +export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/google_gemini-2.5-pro TEMP_0.7.js b/tests/8_json_validator/outputs/google_gemini-2.5-pro TEMP_0.7.js new file mode 100644 index 0000000..5aa6d27 --- /dev/null +++ b/tests/8_json_validator/outputs/google_gemini-2.5-pro TEMP_0.7.js @@ -0,0 +1,32 @@ +let ajvPromise; +const compiledSchemas = new WeakMap(); + +const validateJSON = async (json, schema) => { + try { + ajvPromise ||= import('https://esm.sh/ajv@8').then( + ({ default: Ajv }) => new Ajv({ allErrors: true }) + ); + const ajv = await ajvPromise; + + let validate = compiledSchemas.get(schema); + if (!validate) { + validate = ajv.compile(schema); + compiledSchemas.set(schema, validate); + } + + const valid = validate(json); + const errors = valid + ? [] + : (validate.errors ?? []).map(({ instancePath, message }) => + `${instancePath.substring(1) || 'root'}: ${message}` + ); + + return { valid, errors }; + } catch (error) { + return { + valid: false, + errors: [error.message || 'An unknown validation error occurred.'], + }; + } +}; +export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openai_gpt-5-codex.js b/tests/8_json_validator/outputs/openai_gpt-5-codex.js new file mode 100644 index 0000000..2bf20b0 --- /dev/null +++ b/tests/8_json_validator/outputs/openai_gpt-5-codex.js @@ -0,0 +1,17 @@ +let ajvReady +const loadAjv=()=>ajvReady??=(async()=>{ + const {default:Ajv}=await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv2020.mjs') + return new Ajv({allErrors:true,strict:false}) +})() +async function validateJSON(data,schema){ + const ajv=await loadAjv() + const validate=ajv.compile(schema) + const valid=validate(data) + const errors=valid?[]:validate.errors?.map(({instancePath,message,params})=>{ + const here=instancePath||'/' + const extra=params&&Object.keys(params).length?JSON.stringify(params):'' + return [here,message,extra].filter(Boolean).join(' ') + })||[] + return {valid,errors} +} +export default validateJSON; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openrouter_polaris-alpha.js b/tests/8_json_validator/outputs/openrouter_polaris-alpha.js new file mode 100644 index 0000000..7e0f540 --- /dev/null +++ b/tests/8_json_validator/outputs/openrouter_polaris-alpha.js @@ -0,0 +1,15 @@ +async function validateJSON(data, schema) { + const {default: Ajv} = await import('https://cdn.jsdelivr.net/npm/ajv@8/dist/ajv.min.js') + const ajv = new Ajv({allErrors:true, strict:false}) + const validate = ajv.compile(schema) + const valid = validate(data) + if (valid) return {valid:true, errors:[]} + const errors = (validate.errors || []).map(e => { + const path = (e.instancePath || e.dataPath || '') || (e.schemaPath || '') + const msg = e.message || 'Invalid value' + const params = e.params ? JSON.stringify(e.params) : '' + return [path, msg, params].filter(Boolean).join(' - ') + }) + return {valid:false, errors} +} +export default validateJSON; \ No newline at end of file