diff --git a/tests/10_scrypt_hash/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/10_scrypt_hash/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..b3cfadd --- /dev/null +++ b/tests/10_scrypt_hash/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,9 @@ +const hashPassword = async (password, salt) => { + const { scrypt } = await import("https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm"); + const enc = new TextEncoder(); + const hash = await scrypt(enc.encode(password), enc.encode(salt), 1024, 8, 1, 32); + return [...hash].map(b => b.toString(16).padStart(2, "0")).join(""); +}; +export default hashPassword; +// Generation time: 2.918s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/11_geospatial/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..31e7897 --- /dev/null +++ b/tests/11_geospatial/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,12 @@ +async function analyzeGPS(readings, boundary) { + const turf = await import("https://cdn.skypack.dev/@turf/turf"); + const inside = readings + .filter((r) => turf.booleanPointInPolygon(turf.point(r.loc), boundary)) + .sort((a, b) => a.ts - b.ts); + if (inside.length < 2) return 0; + const line = turf.lineString(inside.map((r) => r.loc)); + return Math.round(turf.length(line, { units: "kilometers" }) * 100) / 100; +} +export default analyzeGPS; +// Generation time: 2.996s +// Result: FAIL \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/12_mst_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..f947214 --- /dev/null +++ b/tests/12_mst_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,71 @@ +async function computeMST(toml) { + const [{ parse }, mnemonist, textTableMod] = await Promise.all([ + import("https://esm.sh/smol-toml"), + import("https://esm.sh/mnemonist"), + import("https://esm.sh/text-table") + ]); + + const Heap = mnemonist.Heap || mnemonist.default.Heap; + const table = textTableMod.default || textTableMod; + + const edges = parse(toml).edges || []; + const heap = new Heap((a, b) => a.weight - b.weight); + const nodes = new Set(); + + for (const e of edges) { + heap.push(e); + nodes.add(e.from); + nodes.add(e.to); + } + + const parent = new Map(); + const rank = new Map(); + for (const n of nodes) { + parent.set(n, n); + rank.set(n, 0); + } + + const find = x => { + let r = x; + while (parent.get(r) !== r) r = parent.get(r); + while (parent.get(x) !== r) { + const next = parent.get(x); + parent.set(x, r); + x = next; + } + return r; + }; + + const union = (a, b) => { + const ra = find(a), rb = find(b); + if (ra === rb) return false; + const da = rank.get(ra), db = rank.get(rb); + if (da < db) parent.set(ra, rb); + else if (da > db) parent.set(rb, ra); + else { + parent.set(rb, ra); + rank.set(ra, da + 1); + } + return true; + }; + + const rows = []; + let totalWeight = 0; + const need = Math.max(nodes.size - 1, 0); + + while (heap.size && rows.length < need) { + const e = heap.pop(); + if (union(e.from, e.to)) { + rows.push([e.from, e.to, String(e.weight)]); + totalWeight += e.weight; + } + } + + return { + table: table([["From", "To", "Weight"], ...rows]), + totalWeight + }; +} +export default computeMST; +// Generation time: 8.341s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/1_dijkstra/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..931c858 --- /dev/null +++ b/tests/1_dijkstra/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,24 @@ +async function findShortestPath(graph, start, end) { + const { default: PriorityQueue } = await import("https://esm.sh/js-priority-queue"); + const dist = {}; + for (const node in graph) dist[node] = Infinity; + dist[start] = 0; + const pq = new PriorityQueue({ comparator: (a, b) => a.cost - b.cost }); + pq.queue({ node: start, cost: 0 }); + while (pq.length) { + const { node, cost } = pq.dequeue(); + if (node === end) return cost; + if (cost > dist[node]) continue; + for (const next in graph[node]) { + const nc = cost + graph[node][next]; + if (nc < dist[next]) { + dist[next] = nc; + pq.queue({ node: next, cost: nc }); + } + } + } + return dist[end] ?? Infinity; +} +export default findShortestPath; +// Generation time: 5.506s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/2_convex_hull/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..1fa6e65 --- /dev/null +++ b/tests/2_convex_hull/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,29 @@ +const findConvexHull = async (points) => { + const { default: _ } = await import("https://cdn.skypack.dev/lodash"); + + const pts = _.sortBy( + _.uniqBy(points, (p) => `${p.x},${p.y}`), + ["x", "y"] + ); + + if (pts.length < 3) return pts; + + const cross = (o, a, b) => + (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + + const build = (arr) => { + const h = []; + for (const p of arr) { + while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) + h.pop(); + h.push(p); + } + h.pop(); + return h; + }; + + return [...build(pts), ...build([...pts].reverse())]; +}; +export default findConvexHull; +// Generation time: 4.735s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/3_signal_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js new file mode 100644 index 0000000..c50af50 --- /dev/null +++ b/tests/3_signal_pipeline/outputs/anthropic_claude-opus-4.8 EFF_medium.js @@ -0,0 +1,65 @@ +const CDN = { + yaml: "https://cdn.jsdelivr.net/npm/js-yaml/+esm", + math: "https://cdn.jsdelivr.net/npm/mathjs/+esm", + ndarray: "https://cdn.jsdelivr.net/npm/ndarray/+esm", + fft: "https://cdn.jsdelivr.net/npm/ndarray-fft/+esm", + purify: "https://cdn.jsdelivr.net/npm/dompurify/+esm" +}; + +const def = m => m.default ?? m; + +export async function analyzeSignal(yamlStr) { + const [yamlMod, math, ndMod, fftMod, purifyMod] = await Promise.all([ + import(CDN.yaml), + import(CDN.math), + import(CDN.ndarray), + import(CDN.fft), + import(CDN.purify) + ]); + + const yaml = def(yamlMod); + const ndarray = def(ndMod); + const fft = def(fftMod); + const DOMPurify = def(purifyMod); + + const cfg = yaml.load(yamlStr); + const { sampleRate, duration, components = [] } = cfg; + const N = sampleRate * duration; + + const signal = Array.from({ length: N }, (_, i) => { + const t = i / sampleRate; + return components.reduce( + (s, { amplitude, frequency }) => + s + amplitude * math.sin(2 * math.pi * frequency * t), + 0 + ); + }); + + const real = ndarray(new Float64Array(signal), [N]); + const imag = ndarray(new Float64Array(N), [N]); + fft(1, real, imag); + + const half = N / 2; + const peaks = []; + for (let k = 0; k <= half; k++) { + const mag = math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / half; + if (mag > 0.1) + peaks.push({ + frequencyHz: Math.round((k * sampleRate) / N), + magnitude: Math.round(mag * 100) / 100 + }); + } + peaks.sort((a, b) => b.magnitude - a.magnitude); + + const rows = peaks + .map(p => `
| Frequency (Hz) | Magnitude |
|---|
${tableString}`
+ );
+
+ return {
+ valid: true,
+ label: config.label,
+ stats: { mean, stddev, median },
+ table: sanitized,
+ count: config.count
+ };
+};
+
+export { hexchain };
+export default hexchain;
+// Generation time: 8.247s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/5_markdown_parser/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/5_markdown_parser/outputs/anthropic_claude-opus-4.8 EFF_medium.js
new file mode 100644
index 0000000..0025a3e
--- /dev/null
+++ b/tests/5_markdown_parser/outputs/anthropic_claude-opus-4.8 EFF_medium.js
@@ -0,0 +1,9 @@
+const parseMarkdown = async (md = "") => {
+ const { marked } = await import("https://cdn.jsdelivr.net/npm/marked/+esm");
+ return marked.parse(md, { gfm: true, breaks: true });
+};
+
+
+export default parseMarkdown;
+// Generation time: 6.625s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/6_csv_processor/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/6_csv_processor/outputs/anthropic_claude-opus-4.8 EFF_medium.js
new file mode 100644
index 0000000..137455b
--- /dev/null
+++ b/tests/6_csv_processor/outputs/anthropic_claude-opus-4.8 EFF_medium.js
@@ -0,0 +1,29 @@
+const processCSV = async (csv, config) => {
+ const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
+ const [{ default: Papa }, { default: _ }] = await Promise.all([
+ import("https://esm.sh/papaparse@5.4.1"),
+ import("https://esm.sh/lodash-es@4.17.21")
+ ]);
+
+ const { data } = Papa.parse(csv.trim(), { header: true, skipEmptyLines: true });
+ const num = v => {
+ const n = Number(v);
+ return isNaN(n) ? 0 : n;
+ };
+
+ const filtered = data.filter(r => r[filterColumn] == filterValue);
+ const groups = _.groupBy(filtered, r => r[groupBy]);
+
+ return _.map(groups, (rows, key) => {
+ const vals = rows.map(r => num(r[aggregateColumn]));
+ const sum = _.sum(vals);
+ const result =
+ operation === "sum" ? sum :
+ operation === "avg" ? sum / rows.length :
+ rows.length;
+ return { [groupBy]: key, result };
+ });
+};
+export default processCSV;
+// Generation time: 6.170s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/7_scheduler/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/7_scheduler/outputs/anthropic_claude-opus-4.8 EFF_medium.js
new file mode 100644
index 0000000..68c7df1
--- /dev/null
+++ b/tests/7_scheduler/outputs/anthropic_claude-opus-4.8 EFF_medium.js
@@ -0,0 +1,53 @@
+async function findAvailableSlots(cal1, cal2, constraints) {
+ const { DateTime } = await import('https://cdn.skypack.dev/luxon');
+ const { durationMinutes: dur, searchRange, workHours } = constraints;
+ const opt = { zone: 'utc' };
+ const toDT = s => DateTime.fromISO(s, opt);
+ const rs = toDT(searchRange.start), re = toDT(searchRange.end);
+ const [wsH, wsM] = workHours.start.split(':').map(Number);
+ const [weH, weM] = workHours.end.split(':').map(Number);
+
+ const busy = [...cal1, ...cal2]
+ .map(b => [toDT(b.start), toDT(b.end)])
+ .filter(([s, e]) => e > s)
+ .sort((a, b) => a[0] - b[0]);
+
+ const merged = [];
+ for (const [s, e] of busy) {
+ const last = merged[merged.length - 1];
+ if (last && s <= last[1]) {
+ if (e > last[1]) last[1] = e;
+ } else merged.push([s, e]);
+ }
+
+ const slots = [];
+ for (let day = rs.startOf('day'); day < re; day = day.plus({ days: 1 })) {
+ const ws = day.set({ hour: wsH, minute: wsM, second: 0, millisecond: 0 });
+ const we = day.set({ hour: weH, minute: weM, second: 0, millisecond: 0 });
+ const winS = ws > rs ? ws : rs;
+ const winE = we < re ? we : re;
+ if (winS >= winE) continue;
+
+ const free = [];
+ let cur = winS;
+ for (const [bs, be] of merged) {
+ if (be <= cur || bs >= winE) continue;
+ if (bs > cur) free.push([cur, bs]);
+ if (be > cur) cur = be;
+ if (cur >= winE) break;
+ }
+ if (cur < winE) free.push([cur, winE]);
+
+ for (const [fs, fe] of free) {
+ let start = fs;
+ for (let nxt; (nxt = start.plus({ minutes: dur })) <= fe; start = nxt) {
+ slots.push({ start: start.toUTC().toISO(), end: nxt.toUTC().toISO() });
+ }
+ }
+ }
+
+ return slots.sort((a, b) => (a.start < b.start ? -1 : 1));
+}
+export default findAvailableSlots;
+// Generation time: 22.608s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/8_json_validator/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/8_json_validator/outputs/anthropic_claude-opus-4.8 EFF_medium.js
new file mode 100644
index 0000000..766ed2e
--- /dev/null
+++ b/tests/8_json_validator/outputs/anthropic_claude-opus-4.8 EFF_medium.js
@@ -0,0 +1,23 @@
+const validateJSON = async (data, schema) => {
+ try {
+ const { default: Ajv } = await import("https://esm.sh/ajv@8");
+ 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) => `${e.instancePath || "/"} ${e.message}`.trim()
+ ),
+ };
+ } catch (err) {
+ return { valid: false, errors: [err.message] };
+ }
+};
+
+export { validateJSON };
+export default validateJSON;
+// Generation time: 5.406s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/9_stream_visualizer/outputs/anthropic_claude-opus-4.8 EFF_medium.js b/tests/9_stream_visualizer/outputs/anthropic_claude-opus-4.8 EFF_medium.js
new file mode 100644
index 0000000..aad436c
--- /dev/null
+++ b/tests/9_stream_visualizer/outputs/anthropic_claude-opus-4.8 EFF_medium.js
@@ -0,0 +1,22 @@
+async function createStreamVisualizer(asyncIterable, options) {
+ const { maxPoints, alpha, width, height, yDomain } = options;
+ const { scaleLinear, line } = await import("https://cdn.skypack.dev/d3");
+ const data = [];
+ let prevEma;
+ for await (const value of asyncIterable) {
+ prevEma = prevEma === undefined ? value : alpha * value + (1 - alpha) * prevEma;
+ data.push({ timestamp: Date.now(), value, ema: prevEma });
+ if (data.length > maxPoints) data.splice(0, data.length - maxPoints);
+ }
+ const x = scaleLinear()
+ .domain([data[0]?.timestamp ?? 0, data.at(-1)?.timestamp ?? 1])
+ .range([0, width]);
+ const y = scaleLinear().domain(yDomain).range([height, 0]);
+ const path = line()
+ .x(d => x(d.timestamp))
+ .y(d => y(d.ema))(data) ?? "";
+ return { data, path };
+}
+export default createStreamVisualizer;
+// Generation time: 4.318s
+// Result: FAIL
\ No newline at end of file