mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Docs: Update benchmark results
This commit is contained in:
39
results.json
39
results.json
@@ -1,11 +1,44 @@
|
|||||||
{
|
{
|
||||||
"google/gemini-2.5-pro": {
|
"google/gemini-2.5-pro": {
|
||||||
"1_dijkstra": 68.831806591
|
"1_dijkstra": 37.563614472,
|
||||||
|
"2_convex_hull": 30.02974868399999,
|
||||||
|
"3_lis": 42.240308332,
|
||||||
|
"4_determinant": 13.347867265000009
|
||||||
|
},
|
||||||
|
"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
|
||||||
},
|
},
|
||||||
"anthropic/claude-sonnet-4.5": {
|
"anthropic/claude-sonnet-4.5": {
|
||||||
"1_dijkstra": 5.513186071999997
|
"1_dijkstra": 13.460692856000039,
|
||||||
|
"2_convex_hull": 5.613852328000008,
|
||||||
|
"3_lis": 2.8292644480000018,
|
||||||
|
"4_determinant": 3.0375356369999937
|
||||||
|
},
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"anthropic/claude-sonnet-4.5 TEMP:0.4": {
|
||||||
|
"1_dijkstra": null,
|
||||||
|
"2_convex_hull": 6.095885308999976,
|
||||||
|
"3_lis": 3.749924349999987,
|
||||||
|
"4_determinant": 12.665039036000032
|
||||||
},
|
},
|
||||||
"openai/gpt-5-codex": {
|
"openai/gpt-5-codex": {
|
||||||
"1_dijkstra": 126.619165211
|
"1_dijkstra": 97.35094948799996,
|
||||||
|
"2_convex_hull": 145.25300972899993,
|
||||||
|
"3_lis": 53.988241607000006,
|
||||||
|
"4_determinant": 6.342495287999976
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
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 visited = new Set();
|
||||||
|
|
||||||
|
while (pq.length) {
|
||||||
|
const { node, dist } = pq.dequeue();
|
||||||
|
|
||||||
|
if (visited.has(node)) continue;
|
||||||
|
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]) {
|
||||||
|
distances[neighbor] = newDist;
|
||||||
|
pq.queue({ node: neighbor, dist: newDist });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return distances[end];
|
||||||
|
}
|
||||||
|
export default findShortestPath;
|
||||||
@@ -1,23 +1,35 @@
|
|||||||
async function findShortestPath(graph, start, end) {
|
const findShortestPath = async (graph, start, end) => {
|
||||||
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm');
|
const { default: PriorityQueue } = await import(
|
||||||
const distances = Object.keys(graph).reduce((acc, node) => ({ ...acc, [node]: Infinity }), {});
|
'https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm'
|
||||||
distances[start] = 0;
|
);
|
||||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
|
||||||
pq.queue([start, 0]);
|
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 });
|
||||||
const visited = new Set();
|
const visited = new Set();
|
||||||
while (pq.length > 0) {
|
|
||||||
const [current, currentDist] = pq.dequeue();
|
pq.queue({ node: start, dist: 0 });
|
||||||
if (visited.has(current)) continue;
|
|
||||||
visited.add(current);
|
while (pq.length) {
|
||||||
if (current === end) return currentDist;
|
const { node, dist } = pq.dequeue();
|
||||||
for (const [neighbor, weight] of Object.entries(graph[current] || {})) {
|
|
||||||
const newDist = currentDist + weight;
|
if (visited.has(node)) continue;
|
||||||
|
if (node === end) return dist;
|
||||||
|
|
||||||
|
visited.add(node);
|
||||||
|
|
||||||
|
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
|
||||||
|
const newDist = dist + weight;
|
||||||
if (newDist < distances[neighbor]) {
|
if (newDist < distances[neighbor]) {
|
||||||
distances[neighbor] = newDist;
|
distances[neighbor] = newDist;
|
||||||
pq.queue([neighbor, newDist]);
|
pq.queue({ node: neighbor, dist: newDist });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return distances[end];
|
return distances[end];
|
||||||
}
|
};
|
||||||
export default findShortestPath;
|
export default findShortestPath;
|
||||||
27
tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js
Normal file
27
tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.4.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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;
|
||||||
27
tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js
Normal file
27
tests/1_dijkstra/outputs/google_gemini-2.5-pro TEMP_0.7.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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.priority - b.priority });
|
||||||
|
|
||||||
|
pq.queue({ value: startNode, priority: 0 });
|
||||||
|
|
||||||
|
while (pq.length) {
|
||||||
|
const { value: currentNode } = pq.dequeue();
|
||||||
|
|
||||||
|
if (currentNode === endNode) break;
|
||||||
|
|
||||||
|
const neighbors = graph[currentNode] ?? {};
|
||||||
|
for (const [neighbor, weight] of Object.entries(neighbors)) {
|
||||||
|
const newDist = distances[currentNode] + weight;
|
||||||
|
|
||||||
|
if (newDist < (distances[neighbor] ?? Infinity)) {
|
||||||
|
distances[neighbor] = newDist;
|
||||||
|
pq.queue({ value: neighbor, priority: newDist });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return distances[endNode] ?? Infinity;
|
||||||
|
}
|
||||||
|
export default findShortestPath;
|
||||||
@@ -1,2 +1,32 @@
|
|||||||
const findShortestPath = async (graph, start, end) => (async () => { const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/priority-queue.min.js'); const dists = Object.fromEntries(Object.keys(graph).map(k => [k, Infinity])), pq = new PQ({ comparator: (a, b) => a[1] - b[1] }); dists[start] = 0; pq.queue([start, 0]); while (pq.length) { const [node] = pq.dequeue(); if (node === end) break; for (const [neighbor, weight] of Object.entries(graph[node] || {})) { const newDist = dists[node] + weight; if (newDist < dists[neighbor]) { dists[neighbor] = newDist; pq.queue([neighbor, newDist]); } } } return dists[end]; })();
|
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;
|
export default findShortestPath;
|
||||||
@@ -1,2 +1,29 @@
|
|||||||
async function findShortestPath(graph,start,end){const{default:PriorityQueue}=await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.3.0/dist/priority-queue.esm.js');if(start==null||end==null)return Infinity;if(start===end)return 0;if(!graph||!Object.prototype.hasOwnProperty.call(graph,start))return Infinity;const visited=new Set;const dist=new Map([[start,0]]);const pq=new PriorityQueue({comparator:(a,b)=>a[0]-b[0]});pq.queue([0,start]);for(;pq.length;){const[d,node]=pq.dequeue();if(visited.has(node))continue;visited.add(node);if(node===end)return d;const neighbors=graph[node]||{};for(const[neighbor,weight]of Object.entries(neighbors)){if(typeof weight!=='number'||weight<0)continue;const alt=d+weight;if(alt<(dist.get(neighbor)??Infinity)){dist.set(neighbor,alt);pq.queue([alt,neighbor]);}}}return Infinity;}
|
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;
|
||||||
|
}
|
||||||
export default findShortestPath;
|
export default findShortestPath;
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
const { sortBy, uniqWith } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js');
|
||||||
|
|
||||||
|
if (points.length < 3) return points;
|
||||||
|
|
||||||
|
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 = arr => {
|
||||||
|
const hull = [];
|
||||||
|
for (const p of arr) {
|
||||||
|
while (hull.length > 1 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
||||||
|
hull.pop();
|
||||||
|
}
|
||||||
|
hull.push(p);
|
||||||
|
}
|
||||||
|
hull.pop();
|
||||||
|
return hull;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lower = buildHull(sorted);
|
||||||
|
const upper = buildHull([...sorted].reverse());
|
||||||
|
|
||||||
|
return [...lower, ...upper].reverse();
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
const { sortBy, uniqWith } = await import('https://cdn.skypack.dev/lodash');
|
||||||
|
|
||||||
|
if (points.length < 3) return points;
|
||||||
|
|
||||||
|
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 = arr => {
|
||||||
|
const hull = [];
|
||||||
|
for (const p of arr) {
|
||||||
|
while (hull.length > 1 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
|
||||||
|
hull.pop();
|
||||||
|
}
|
||||||
|
hull.push(p);
|
||||||
|
}
|
||||||
|
hull.pop();
|
||||||
|
return hull;
|
||||||
|
};
|
||||||
|
|
||||||
|
return [...buildHull(sorted), ...buildHull(sorted.slice().reverse())];
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
29
tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js
Normal file
29
tests/2_convex_hull/outputs/anthropic_claude-sonnet-4.5.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
const { sortBy, uniqWith, isEqual } = 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']);
|
||||||
|
|
||||||
|
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 hull = [];
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
hull.pop();
|
||||||
|
return hull;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lower = buildHull(sorted);
|
||||||
|
const upper = buildHull([...sorted].reverse());
|
||||||
|
|
||||||
|
return [...lower, ...upper].reverse();
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
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;
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
async function findConvexHull(points) {
|
||||||
|
const _ = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
|
||||||
|
|
||||||
|
const uniqueSortedPoints = _.sortBy(
|
||||||
|
_.uniqBy(points, p => `${p.x}:${p.y}`),
|
||||||
|
['x', 'y']
|
||||||
|
);
|
||||||
|
|
||||||
|
if (uniqueSortedPoints.length < 3) {
|
||||||
|
return uniqueSortedPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 = [];
|
||||||
|
for (const p of pts) {
|
||||||
|
while (half.length >= 2 && crossProduct(half.at(-2), half.at(-1), p) <= 0) {
|
||||||
|
half.pop();
|
||||||
|
}
|
||||||
|
half.push(p);
|
||||||
|
}
|
||||||
|
return half;
|
||||||
|
};
|
||||||
|
|
||||||
|
const lower = buildHalfHull(uniqueSortedPoints);
|
||||||
|
const upper = buildHalfHull([...uniqueSortedPoints].reverse());
|
||||||
|
|
||||||
|
const ccwHull = lower.slice(0, -1).concat(upper.slice(0, -1));
|
||||||
|
|
||||||
|
return [ccwHull[0], ...ccwHull.slice(1).reverse()];
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
35
tests/2_convex_hull/outputs/google_gemini-2.5-pro.js
Normal file
35
tests/2_convex_hull/outputs/google_gemini-2.5-pro.js
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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;
|
||||||
23
tests/2_convex_hull/outputs/openai_gpt-5-codex.js
Normal file
23
tests/2_convex_hull/outputs/openai_gpt-5-codex.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
export default findConvexHull;
|
||||||
17
tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js
Normal file
17
tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.4.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
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) {
|
||||||
|
const pos = bisectLeft(tails, num);
|
||||||
|
tails[pos] = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tails.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default findLISLength;
|
||||||
|
export default findLISLength;
|
||||||
15
tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js
Normal file
15
tests/3_lis/outputs/anthropic_claude-sonnet-4.5 TEMP_0.7.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
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) {
|
||||||
|
const pos = bisectLeft(tails, num);
|
||||||
|
tails[pos] = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tails.length;
|
||||||
|
};
|
||||||
|
export default findLISLength;
|
||||||
15
tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js
Normal file
15
tests/3_lis/outputs/anthropic_claude-sonnet-4.5.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
const findLISLength = async (nums) => {
|
||||||
|
const { bisectLeft } = await import('https://cdn.skypack.dev/d3-array');
|
||||||
|
|
||||||
|
if (!nums?.length) return 0;
|
||||||
|
|
||||||
|
const tails = [];
|
||||||
|
|
||||||
|
for (const num of nums) {
|
||||||
|
const idx = bisectLeft(tails, num);
|
||||||
|
tails[idx] = num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tails.length;
|
||||||
|
};
|
||||||
|
export default findLISLength;
|
||||||
14
tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js
Normal file
14
tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.4.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
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;
|
||||||
13
tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js
Normal file
13
tests/3_lis/outputs/google_gemini-2.5-pro TEMP_0.7.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
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;
|
||||||
13
tests/3_lis/outputs/google_gemini-2.5-pro.js
Normal file
13
tests/3_lis/outputs/google_gemini-2.5-pro.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
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;
|
||||||
14
tests/3_lis/outputs/openai_gpt-5-codex.js
Normal file
14
tests/3_lis/outputs/openai_gpt-5-codex.js
Normal file
@@ -0,0 +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;
|
||||||
|
}
|
||||||
|
export default findLISLength;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const calculateDeterminant = async (matrix) => {
|
||||||
|
const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm');
|
||||||
|
return det(matrix);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const calculateDeterminant = async (matrix) => {
|
||||||
|
const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm');
|
||||||
|
return det(matrix);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
const calculateDeterminant = async (matrix) => {
|
||||||
|
const { det } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.11.0/+esm');
|
||||||
|
return det(matrix);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
@@ -0,0 +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);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
@@ -0,0 +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);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
5
tests/4_determinant/outputs/google_gemini-2.5-pro.js
Normal file
5
tests/4_determinant/outputs/google_gemini-2.5-pro.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const calculateDeterminant = async (matrix) => {
|
||||||
|
const { det } = await import('https://esm.sh/mathjs');
|
||||||
|
return det(matrix);
|
||||||
|
};
|
||||||
|
export default calculateDeterminant;
|
||||||
7
tests/4_determinant/outputs/openai_gpt-5-codex.js
Normal file
7
tests/4_determinant/outputs/openai_gpt-5-codex.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
export default calculateDeterminant;
|
||||||
Reference in New Issue
Block a user