diff --git a/tests/10_scrypt_hash/outputs/deepseek_deepseek-v3.2.js b/tests/10_scrypt_hash/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..f37c151 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,11 @@ +const hashPassword = async (password, salt) => { + const { scrypt } = await import('https://cdn.skypack.dev/scrypt-js'); + const encoder = new TextEncoder(); + const passwordBytes = encoder.encode(password); + const saltBytes = encoder.encode(salt); + const hashBytes = await scrypt(passwordBytes, saltBytes, 1024, 8, 1, 32); + return Array.from(hashBytes).map(b => b.toString(16).padStart(2, '0')).join(''); +}; +export default hashPassword; +// Generation time: 5.832s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/deepseek_deepseek-v3.2.js b/tests/11_geospatial/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..68950fb --- /dev/null +++ b/tests/11_geospatial/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,12 @@ +const analyzeGPS = async (readings, boundary) => { + const turf = await import('https://cdn.skypack.dev/@turf/turf'); + const inside = readings.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary)); + if (inside.length < 2) return 0; + const sorted = inside.sort((a, b) => a.ts - b.ts); + const line = turf.lineString(sorted.map(r => r.loc)); + const length = turf.length(line, { units: 'kilometers' }); + return Math.round(length * 100) / 100; +}; +export default analyzeGPS; +// Generation time: 5.688s +// Result: PASS \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/deepseek_deepseek-v3.2.js b/tests/1_dijkstra/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..dc0e0e0 --- /dev/null +++ b/tests/1_dijkstra/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,33 @@ +const findShortestPath = async (graph, start, end) => { + const { PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@latest/+esm'); + const distances = {}; + const previous = {}; + const visited = new Set(); + const queue = new PriorityQueue({ comparator: (a, b) => a.distance - b.distance }); + + Object.keys(graph).forEach(node => distances[node] = Infinity); + distances[start] = 0; + queue.queue({ node: start, distance: 0 }); + + while (queue.length) { + const { node: current } = queue.dequeue(); + if (visited.has(current)) continue; + visited.add(current); + if (current === end) break; + + for (const neighbor in graph[current]) { + const weight = graph[current][neighbor]; + const newDist = distances[current] + weight; + if (newDist < distances[neighbor]) { + distances[neighbor] = newDist; + previous[neighbor] = current; + queue.queue({ node: neighbor, distance: newDist }); + } + } + } + + return distances[end] === undefined ? Infinity : distances[end]; +}; +export default findShortestPath; +// Generation time: 9.823s +// Result: FAIL \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/deepseek_deepseek-v3.2.js b/tests/2_convex_hull/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..72c2f41 --- /dev/null +++ b/tests/2_convex_hull/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,21 @@ +const findConvexHull = async (points) => { + const _ = await import('https://cdn.skypack.dev/lodash'); + const sorted = _.uniqBy(points, p => `${p.x},${p.y}`).sort((a, b) => a.x - b.x || a.y - b.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.concat(upper); +}; +export default findConvexHull; +// Generation time: 9.132s +// Result: PASS \ No newline at end of file diff --git a/tests/3_lis/outputs/deepseek_deepseek-v3.2.js b/tests/3_lis/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..642ca3d --- /dev/null +++ b/tests/3_lis/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,12 @@ +async function findLISLength(arr) { + const d3 = await import('https://esm.sh/d3-array@3.2.4'); + const tails = []; + for (const num of arr) { + const i = d3.bisectLeft(tails, num); + tails[i] = num; + } + return tails.length; +} +export default findLISLength; +// Generation time: 3.865s +// Result: PASS \ No newline at end of file diff --git a/tests/4_transpiler/outputs/deepseek_deepseek-v3.2.js b/tests/4_transpiler/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..42d61e3 --- /dev/null +++ b/tests/4_transpiler/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,8 @@ +const renderTemplate = async (templateString, data) => { + const { default: Handlebars } = await import('https://cdn.skypack.dev/handlebars'); + const template = Handlebars.compile(templateString); + return template(data); +}; +export default renderTemplate; +// Generation time: 3.202s +// Result: PASS \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/deepseek_deepseek-v3.2.js b/tests/5_markdown_parser/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..18f817b --- /dev/null +++ b/tests/5_markdown_parser/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,9 @@ +async function parseMarkdown(markdown) { + const { marked } = await import('https://cdn.jsdelivr.net/npm/marked/lib/marked.esm.js'); + const { gfmHeadingId } = await import('https://cdn.jsdelivr.net/npm/marked-gfm-heading-id/+esm'); + marked.use(gfmHeadingId()); + return marked.parse(markdown, { async: false, gfm: true, breaks: true }); +} +export default parseMarkdown; +// Generation time: 4.398s +// Result: PASS \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/deepseek_deepseek-v3.2.js b/tests/6_csv_processor/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..65c932d --- /dev/null +++ b/tests/6_csv_processor/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,30 @@ +async function processCSV(csv, config) { + const { Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5.4.1/+esm'); + const { groupBy, sumBy, meanBy } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm'); + + const parsed = Papa.parse(csv, { header: true, skipEmptyLines: true }); + const rows = parsed.data.filter(r => r[config.filterColumn] == config.filterValue); + + const numericRows = rows.map(r => ({ + ...r, + [config.aggregateColumn]: Number(r[config.aggregateColumn]) || 0 + })); + + const grouped = groupBy(numericRows, config.groupBy); + const result = Object.entries(grouped).map(([key, group]) => { + let val; + if (config.operation === 'sum') { + val = sumBy(group, config.aggregateColumn); + } else if (config.operation === 'avg') { + val = meanBy(group, config.aggregateColumn); + } else { + val = group.length; + } + return { [config.groupBy]: key, result: val }; + }); + + return result; +} +export default processCSV; +// Generation time: 10.647s +// Result: FAIL \ No newline at end of file diff --git a/tests/7_scheduler/outputs/deepseek_deepseek-v3.2.js b/tests/7_scheduler/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..b08c84b --- /dev/null +++ b/tests/7_scheduler/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,52 @@ +const findAvailableSlots = async (calendar1, calendar2, constraints) => { + const { DateTime, Interval } = await import('https://cdn.jsdelivr.net/npm/luxon@3.4.4/+esm'); + + const parse = s => DateTime.fromISO(s, { zone: 'utc' }); + const workStart = constraints.workHours.start; + const workEnd = constraints.workHours.end; + const rangeStart = parse(constraints.searchRange.start); + const rangeEnd = parse(constraints.searchRange.end); + const duration = constraints.durationMinutes; + + const allBusy = [...calendar1, ...calendar2] + .map(b => Interval.fromDateTimes(parse(b.start), parse(b.end))) + .sort((a, b) => a.s - b.s); + + const merged = []; + allBusy.forEach(busy => { + const last = merged[merged.length - 1]; + last && last.overlaps(busy) || last?.abutsStart(busy) ? + merged[merged.length - 1] = last.union(busy) : merged.push(busy); + }); + + const free = []; + let current = rangeStart; + merged.forEach(busy => { + if (current < busy.s) free.push(Interval.fromDateTimes(current, busy.s)); + current = busy.e > current ? busy.e : current; + }); + if (current < rangeEnd) free.push(Interval.fromDateTimes(current, rangeEnd)); + + const slots = []; + free.forEach(interval => { + let slotStart = interval.s; + const workStartToday = slotStart.set({ hour: workStart.slice(0, 2), minute: workStart.slice(3), second: 0, millisecond: 0 }); + const workEndToday = slotStart.set({ hour: workEnd.slice(0, 2), minute: workEnd.slice(3), second: 0, millisecond: 0 }); + const workInterval = Interval.fromDateTimes(workStartToday, workEndToday); + const available = interval.intersection(workInterval); + + if (available) { + let start = available.s > slotStart ? available.s : slotStart; + while (start.plus({ minutes: duration }) <= available.e && start.plus({ minutes: duration }) <= rangeEnd) { + const end = start.plus({ minutes: duration }); + slots.push({ start: start.toISO(), end: end.toISO() }); + start = end; + } + } + }); + + return slots; +}; +export default findAvailableSlots; +// Generation time: 19.693s +// Result: PASS \ No newline at end of file diff --git a/tests/8_json_validator/outputs/deepseek_deepseek-v3.2.js b/tests/8_json_validator/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..237f01a --- /dev/null +++ b/tests/8_json_validator/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,13 @@ +const validateJSON = async (json, schema) => { + const { default: Ajv } = await import('https://cdn.skypack.dev/ajv@8.12.0'); + const ajv = new Ajv({ allErrors: true }); + const validate = ajv.compile(schema); + const valid = validate(json); + return { + valid, + errors: valid ? [] : validate.errors.map(e => `${e.instancePath} ${e.message}`) + }; +}; +export default validateJSON; +// Generation time: 4.839s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/deepseek_deepseek-v3.2.js b/tests/9_stream_visualizer/outputs/deepseek_deepseek-v3.2.js new file mode 100644 index 0000000..ce951c4 --- /dev/null +++ b/tests/9_stream_visualizer/outputs/deepseek_deepseek-v3.2.js @@ -0,0 +1,24 @@ +const createStreamVisualizer = async (asyncIterable, options) => { + const { maxPoints = 100, alpha = 0.1, width = 800, height = 400, yDomain = [0, 100] } = options; + const data = []; + let ema = null; + let firstTimestamp = null; + + for await (const { timestamp, value } of asyncIterable) { + ema = ema === null ? value : alpha * value + (1 - alpha) * ema; + data.push({ timestamp, value, ema }); + if (data.length > maxPoints) data.shift(); + if (firstTimestamp === null) firstTimestamp = timestamp; + } + + const d3 = await import('https://esm.sh/d3@7'); + const xScale = d3.scaleLinear().domain([firstTimestamp, data[data.length - 1].timestamp]).range([0, width]); + const yScale = d3.scaleLinear().domain(yDomain).range([height, 0]); + const line = d3.line().x(d => xScale(d.timestamp)).y(d => yScale(d.ema)); + const path = line(data); + + return { data, path }; +}; +export default createStreamVisualizer; +// Generation time: 9.968s +// Result: PASS \ No newline at end of file