diff --git a/tests/10_scrypt_hash/outputs/google_gemini-3.7-flash EFF_high.js b/tests/10_scrypt_hash/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..c463402 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,16 @@ +export async function hashPassword(password, salt) { + const { scrypt } = await import('https://esm.sh/scrypt-js'); + const enc = new TextEncoder(); + const hash = await scrypt( + enc.encode(password), + enc.encode(salt), + 1024, + 8, + 1, + 32 + ); + return Array.from(hash, (b) => b.toString(16).padStart(2, '0')).join(''); +} +export default hashPassword; +// Generation time: 8.431s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/google_gemini-3.7-flash EFF_high.js b/tests/11_geospatial/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..8a2adfd --- /dev/null +++ b/tests/11_geospatial/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,16 @@ +export async function analyzeGPS(readings, boundary) { + const { booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf'); + + const pts = readings + .filter(r => booleanPointInPolygon(r.loc, boundary)) + .sort((a, b) => a.ts - b.ts) + .map(r => r.loc); + + if (pts.length < 2) return 0; + + const totalLength = length(lineString(pts), { units: 'kilometers' }); + return +totalLength.toFixed(2); +} +export default analyzeGPS; +// Generation time: 9.365s +// Result: PASS \ No newline at end of file diff --git a/tests/12_mst_pipeline/outputs/google_gemini-3.7-flash EFF_high.js b/tests/12_mst_pipeline/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..c16a05f --- /dev/null +++ b/tests/12_mst_pipeline/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,73 @@ +export async function computeMST(tomlString) { + const [{ parse }, mnemonist, textTableMod] = await Promise.all([ + import('https://esm.sh/smol-toml'), + import('https://esm.sh/mnemonist/heap'), + import('https://esm.sh/text-table') + ]); + + const Heap = mnemonist.default ?? mnemonist.Heap ?? mnemonist; + const textTable = textTableMod.default ?? textTableMod; + + const { edges = [] } = parse(tomlString); + const parent = new Map(); + const rank = new Map(); + + for (const { from, to } of edges) { + if (!parent.has(from)) parent.set(from, from), rank.set(from, 0); + if (!parent.has(to)) parent.set(to, to), rank.set(to, 0); + } + + const find = (n) => { + let root = n; + while (root !== parent.get(root)) root = parent.get(root); + let curr = n; + while (curr !== root) { + const next = parent.get(curr); + parent.set(curr, root); + curr = next; + } + return root; + }; + + const union = (u, v) => { + let rootU = find(u); + let rootV = find(v); + if (rootU === rootV) return false; + + const rankU = rank.get(rootU); + const rankV = rank.get(rootV); + if (rankU < rankV) [rootU, rootV] = [rootV, rootU]; + + parent.set(rootV, rootU); + if (rankU === rankV) rank.set(rootU, rankU + 1); + return true; + }; + + const heap = new Heap((a, b) => a.weight - b.weight); + for (const edge of edges) heap.push(edge); + + const mst = []; + let totalWeight = 0; + const targetEdges = Math.max(0, parent.size - 1); + + while (heap.size > 0 && mst.length < targetEdges) { + const edge = heap.pop(); + if (union(edge.from, edge.to)) { + mst.push(edge); + totalWeight += edge.weight; + } + } + + const rows = [ + ['From', 'To', 'Weight'], + ...mst.map(({ from, to, weight }) => [from, to, String(weight)]) + ]; + + return { + table: textTable(rows), + totalWeight + }; +} +export default computeMST; +// Generation time: 18.013s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/google_gemini-3.7-flash EFF_high.js b/tests/1_dijkstra/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..50bd7ad --- /dev/null +++ b/tests/1_dijkstra/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,27 @@ +async function findShortestPath(graph, start, end) { + const { default: PriorityQueue } = await import('https://esm.sh/js-priority-queue'); + const 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 [adj, weight] of Object.entries(graph[node] ?? {})) { + const total = cost + weight; + if (total < (dist[adj] ?? Infinity)) { + dist[adj] = total; + pq.queue({ node: adj, cost: total }); + } + } + } + + return Infinity; +} +export default findShortestPath; +// Generation time: 10.601s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/google_gemini-3.7-flash EFF_high.js b/tests/2_convex_hull/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..d720688 --- /dev/null +++ b/tests/2_convex_hull/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,32 @@ +export async function findConvexHull(points) { + if (!Array.isArray(points) || points.length <= 2) { + return points ? [...points] : []; + } + + const { orderBy, uniqWith, isEqual } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js'); + const pts = orderBy(uniqWith(points, isEqual), ['x', 'y']); + + if (pts.length <= 2) return pts; + + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + + const chain = list => + list.reduce((hull, pt) => { + while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], pt) <= 0) { + hull.pop(); + } + hull.push(pt); + return hull; + }, []); + + const lower = chain(pts); + const upper = chain([...pts].reverse()); + + lower.pop(); + upper.pop(); + + return lower.concat(upper); +} +export default findConvexHull; +// Generation time: 12.593s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/google_gemini-3.7-flash EFF_high.js b/tests/3_signal_pipeline/outputs/google_gemini-3.7-flash EFF_high.js new file mode 100644 index 0000000..ee5c680 --- /dev/null +++ b/tests/3_signal_pipeline/outputs/google_gemini-3.7-flash EFF_high.js @@ -0,0 +1,59 @@ +export async function analyzeSignal(yamlStr) { + const [ + { default: yaml }, + math, + { default: ndarray }, + { default: fft }, + { default: DOMPurify } + ] = await Promise.all([ + import('https://esm.sh/js-yaml'), + import('https://esm.sh/mathjs'), + import('https://esm.sh/ndarray'), + import('https://esm.sh/ndarray-fft'), + import('https://esm.sh/dompurify') + ]); + + const { sampleRate, duration, components } = yaml.load(yamlStr); + const N = sampleRate * duration; + const signal = new Float64Array(N); + + for (let i = 0; i < N; i++) { + const t = i / sampleRate; + signal[i] = components.reduce( + (acc, { frequency, amplitude }) => + acc + 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 peaks = []; + const halfN = N / 2; + + for (let k = 0; k <= halfN; k++) { + const mag = math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / halfN; + 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 |
|---|
${tableStr}`);
+
+ return {
+ valid: true,
+ label: config.label,
+ stats: { mean, stddev, median },
+ table: sanitizedHTML,
+ count: config.count
+ };
+}
+export default hexchain;
+// Generation time: 24.452s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/5_markdown_parser/outputs/google_gemini-3.7-flash EFF_high.js b/tests/5_markdown_parser/outputs/google_gemini-3.7-flash EFF_high.js
new file mode 100644
index 0000000..c611ea8
--- /dev/null
+++ b/tests/5_markdown_parser/outputs/google_gemini-3.7-flash EFF_high.js
@@ -0,0 +1,7 @@
+export async function parseMarkdown(markdown) {
+ const { marked } = await import('https://esm.sh/marked');
+ return marked.parse(markdown ?? '');
+}
+export default parseMarkdown;
+// Generation time: 6.155s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/6_csv_processor/outputs/google_gemini-3.7-flash EFF_high.js b/tests/6_csv_processor/outputs/google_gemini-3.7-flash EFF_high.js
new file mode 100644
index 0000000..3cbd0e0
--- /dev/null
+++ b/tests/6_csv_processor/outputs/google_gemini-3.7-flash EFF_high.js
@@ -0,0 +1,25 @@
+export async function processCSV(csvString, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) {
+ const { parse } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm');
+ const { data } = parse(csvString, { header: true, skipEmptyLines: true });
+
+ const groups = new Map();
+
+ for (const row of data) {
+ if (row[filterColumn] == filterValue) {
+ const key = row[groupBy];
+ const val = +row[aggregateColumn] || 0;
+ const acc = groups.get(key) || { sum: 0, count: 0 };
+ acc.sum += val;
+ acc.count += 1;
+ groups.set(key, acc);
+ }
+ }
+
+ return Array.from(groups, ([key, { sum, count }]) => ({
+ [groupBy]: key,
+ result: operation === 'count' ? count : operation === 'avg' ? sum / count : sum
+ }));
+}
+export default processCSV;
+// Generation time: 12.695s
+// Result: FAIL
\ No newline at end of file
diff --git a/tests/7_scheduler/outputs/google_gemini-3.7-flash EFF_high.js b/tests/7_scheduler/outputs/google_gemini-3.7-flash EFF_high.js
new file mode 100644
index 0000000..a1bd27f
--- /dev/null
+++ b/tests/7_scheduler/outputs/google_gemini-3.7-flash EFF_high.js
@@ -0,0 +1,78 @@
+export async function findAvailableSlots(calendar1 = [], calendar2 = [], constraints) {
+ const { DateTime } = await import('https://cdn.jsdelivr.net/npm/luxon@3.4.4/+esm');
+
+ const durMs = constraints.durationMinutes * 60000;
+ if (!durMs || durMs <= 0) return [];
+
+ const rangeStart = DateTime.fromISO(constraints.searchRange.start, { zone: 'utc' }).toMillis();
+ const rangeEnd = DateTime.fromISO(constraints.searchRange.end, { zone: 'utc' }).toMillis();
+ if (rangeStart >= rangeEnd) return [];
+
+ const [whStartH, whStartM] = constraints.workHours.start.split(':').map(Number);
+ const [whEndH, whEndM] = constraints.workHours.end.split(':').map(Number);
+
+ const busySlots = [...calendar1, ...calendar2]
+ .map(slot => ({
+ start: DateTime.fromISO(slot.start, { zone: 'utc' }).toMillis(),
+ end: DateTime.fromISO(slot.end, { zone: 'utc' }).toMillis()
+ }))
+ .filter(slot => slot.end > slot.start && slot.end > rangeStart && slot.start < rangeEnd)
+ .sort((a, b) => a.start - b.start);
+
+ const mergedBusy = busySlots.reduce((acc, curr) => {
+ if (!acc.length || acc.at(-1).end < curr.start) {
+ acc.push({ ...curr });
+ } else {
+ acc.at(-1).end = Math.max(acc.at(-1).end, curr.end);
+ }
+ return acc;
+ }, []);
+
+ const slots = [];
+ const addSlots = (from, to) => {
+ for (let time = from; time + durMs <= to; time += durMs) {
+ slots.push({
+ start: new Date(time).toISOString(),
+ end: new Date(time + durMs).toISOString()
+ });
+ }
+ };
+
+ let dayCursor = DateTime.fromMillis(rangeStart, { zone: 'utc' }).startOf('day');
+ const lastDay = DateTime.fromMillis(rangeEnd, { zone: 'utc' }).startOf('day');
+
+ while (dayCursor <= lastDay) {
+ const workStart = dayCursor.set({ hour: whStartH, minute: whStartM, second: 0, millisecond: 0 }).toMillis();
+ const workEnd = dayCursor.set({ hour: whEndH, minute: whEndM, second: 0, millisecond: 0 }).toMillis();
+
+ const winStart = Math.max(workStart, rangeStart);
+ const winEnd = Math.min(workEnd, rangeEnd);
+
+ if (winStart < winEnd) {
+ let cursor = winStart;
+
+ for (const busy of mergedBusy) {
+ if (busy.end <= cursor) continue;
+ if (busy.start >= winEnd) break;
+
+ if (busy.start > cursor) {
+ addSlots(cursor, Math.min(busy.start, winEnd));
+ }
+
+ cursor = Math.max(cursor, busy.end);
+ if (cursor >= winEnd) break;
+ }
+
+ if (cursor < winEnd) {
+ addSlots(cursor, winEnd);
+ }
+ }
+
+ dayCursor = dayCursor.plus({ days: 1 });
+ }
+
+ return slots;
+}
+export default findAvailableSlots;
+// Generation time: 32.042s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/8_json_validator/outputs/google_gemini-3.7-flash EFF_high.js b/tests/8_json_validator/outputs/google_gemini-3.7-flash EFF_high.js
new file mode 100644
index 0000000..f3c8539
--- /dev/null
+++ b/tests/8_json_validator/outputs/google_gemini-3.7-flash EFF_high.js
@@ -0,0 +1,14 @@
+export async function validateJSON(data, schema) {
+ const Ajv = (await import('https://esm.sh/ajv@8')).default;
+ const ajv = new Ajv({ allErrors: true, strict: false });
+ const validate = ajv.compile(schema);
+ const valid = Boolean(validate(data));
+ const errors = valid
+ ? []
+ : (validate.errors || []).map(e => `${e.instancePath || '#'} ${e.message}`);
+
+ return { valid, errors };
+}
+export default validateJSON;
+// Generation time: 8.566s
+// Result: PASS
\ No newline at end of file
diff --git a/tests/9_stream_visualizer/outputs/google_gemini-3.7-flash EFF_high.js b/tests/9_stream_visualizer/outputs/google_gemini-3.7-flash EFF_high.js
new file mode 100644
index 0000000..0b9214b
--- /dev/null
+++ b/tests/9_stream_visualizer/outputs/google_gemini-3.7-flash EFF_high.js
@@ -0,0 +1,25 @@
+export async function createStreamVisualizer(
+ asyncIterable,
+ { maxPoints = Infinity, alpha = 0.5, width = 800, height = 400, yDomain = [0, 100] } = {}
+) {
+ const { scaleLinear, line } = await import('d3');
+ const data = [];
+ let ema;
+
+ for await (const { timestamp, value } of asyncIterable) {
+ ema = ema === undefined ? value : alpha * value + (1 - alpha) * ema;
+ data.push({ timestamp, value, ema });
+ if (data.length > maxPoints) data.shift();
+ }
+
+ if (!data.length) return { data, path: '' };
+
+ const x = scaleLinear().domain([data[0].timestamp, data.at(-1).timestamp]).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: 11.140s
+// Result: FAIL
\ No newline at end of file