diff --git a/tests/10_scrypt_hash/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/10_scrypt_hash/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..4597b6d --- /dev/null +++ b/tests/10_scrypt_hash/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,11 @@ +const SCRYPT_URL = "https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm"; + +async function hashPassword(password, salt) { + const { scrypt } = await import(SCRYPT_URL); + 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: 36.726s +// Result: PASS \ No newline at end of file diff --git a/tests/11_geospatial/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/11_geospatial/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..dc2de62 --- /dev/null +++ b/tests/11_geospatial/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,13 @@ +async function analyzeGPS(readings, boundary) { + if (!Array.isArray(readings) || readings.length < 2) return 0; + const m = await import('https://cdn.jsdelivr.net/npm/@turf/turf@7/+esm'); + const { booleanPointInPolygon: inside, lineString, length } = m.default ?? m; + const coords = readings + .filter(({ loc }) => loc && inside(loc, boundary, { ignoreBoundary: true })) + .sort((a, b) => a.ts - b.ts) + .map(({ loc }) => loc); + return coords.length < 2 ? 0 : +length(lineString(coords), { units: 'kilometers' }).toFixed(2); +} +export default analyzeGPS; +// Generation time: 75.533s +// Result: PASS \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..c386871 --- /dev/null +++ b/tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,31 @@ +async function findConvexHull(points) { + if (!Array.isArray(points) || points.some(p => !p || !Number.isFinite(p.x) || !Number.isFinite(p.y))) { + throw new TypeError('findConvexHull expects an array of finite {x, y} points'); + } + + const { sortBy, uniqWith } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm'); + const ps = uniqWith( + sortBy(points.map(({ x, y }) => ({ x, y })), ['x', 'y']), + (a, b) => a.x === b.x && a.y === b.y + ); + + if (ps.length < 3) return ps; + + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x); + const half = q => { + const h = []; + for (const p of q) { + while (h.length > 1 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop(); + h.push(p); + } + return h; + }; + + const lo = half(ps); + const hi = half([...ps].reverse()); + + return [...lo.slice(0, -1), ...hi.slice(0, -1)]; +} +export default findConvexHull; +// Generation time: 96.201s +// Result: PASS \ No newline at end of file diff --git a/tests/3_signal_pipeline/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/3_signal_pipeline/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..1d09ff9 --- /dev/null +++ b/tests/3_signal_pipeline/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,57 @@ +const CDN = [ + 'https://cdn.jsdelivr.net/npm/js-yaml@4.1.0/+esm', + 'https://cdn.jsdelivr.net/npm/mathjs@13/+esm', + 'https://cdn.jsdelivr.net/npm/ndarray@1.0.19/+esm', + 'https://cdn.jsdelivr.net/npm/ndarray-fft@1.0.3/+esm', + 'https://cdn.jsdelivr.net/npm/dompurify@3.1.6/+esm' +]; + +let libs; +const loadLibs = () => (libs ??= Promise.all(CDN.map((u) => import(u)))); +const pick = (m, k) => (m?.[k] !== undefined ? m : m?.default ?? m); + +async function analyzeSignal(yamlString) { + if (typeof yamlString !== 'string') throw new TypeError('analyzeSignal expects a YAML string'); + + const [yamlM, mathM, ndM, fftM, dpM] = await loadLibs(); + const { load } = pick(yamlM, 'load'); + const math = pick(mathM, 'sin'); + const ndarray = ndM?.default ?? ndM; + const fft = fftM?.default ?? fftM; + const DOMPurify = dpM?.default ?? dpM; + + const { sampleRate, duration, components = [] } = load(yamlString); + const N = sampleRate * duration; + if (!Number.isInteger(N) || N < 2 || (N & (N - 1))) { + throw new RangeError(`sampleRate * duration must be a power of two >= 2 (got ${N})`); + } + + const data = new Float64Array(N); + for (let i = 0; i < N; i++) { + const t = i / sampleRate; + data[i] = components.reduce((s, { frequency: f, amplitude: a }) => s + a * math.sin(2 * math.pi * f * t), 0); + } + + const real = ndarray(data, [N]); + const imag = ndarray(new Float64Array(N), [N]); + fft(1, real, imag); + + const half = N >> 1; + const peaks = Array.from({ length: half + 1 }, (_, k) => ({ + k, + m: math.sqrt(real.get(k) ** 2 + imag.get(k) ** 2) / half + })) + .filter(({ m }) => m > 0.1) + .sort((a, b) => b.m - a.m) + .map(({ k, m }) => ({ frequencyHz: Math.round(k * sampleRate / N), magnitude: +m.toFixed(2) })); + + const rows = peaks.map(({ frequencyHz, magnitude }) => `
| Frequency (Hz) | Magnitude |
|---|
' + table + ''), + count: config.count + }; +} +export default hexchain; +// Generation time: 84.644s +// Result: PASS \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/5_markdown_parser/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..90e4946 --- /dev/null +++ b/tests/5_markdown_parser/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,15 @@ +let libs; + +const load = () => libs ??= Promise.all([ + import('https://cdn.jsdelivr.net/npm/marked@12.0.2/+esm'), + import('https://cdn.jsdelivr.net/npm/dompurify@3.1.5/+esm'), +]).then(([{ marked }, { default: purify }]) => ({ marked, purify })); + +async function parseMarkdown(md) { + const { marked, purify } = await load(); + const html = marked.parse(String(md ?? ''), { gfm: true }); + return purify.sanitize(html, { USE_PROFILES: { html: true } }); +} +export default parseMarkdown; +// Generation time: 40.071s +// Result: PASS \ No newline at end of file diff --git a/tests/7_scheduler/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/7_scheduler/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..491378c --- /dev/null +++ b/tests/7_scheduler/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,64 @@ +export async function findAvailableSlots(calendar1, calendar2, constraints) { + const { DateTime } = await import('https://cdn.jsdelivr.net/npm/luxon@3/+esm'); + const utc = (s) => DateTime.fromISO(s, { zone: 'utc' }); + const { durationMinutes, searchRange, workHours } = constraints; + const rs = utc(searchRange.start); + const re = utc(searchRange.end); + + const busy = [...calendar1, ...calendar2] + .map(({ start, end }) => [utc(start), utc(end)]) + .filter(([s, e]) => e > s) + .sort((a, b) => a[0] - b[0]); + + const merged = []; + for (const [s, e] of busy) { + const last = merged.at(-1); + if (last && s <= last[1]) last[1] = e > last[1] ? e : last[1]; + else merged.push([s, e]); + } + + const free = []; + let cur = rs; + for (const [s, e] of merged) { + const bs = s < rs ? rs : s; + const be = e > re ? re : e; + if (be <= rs || bs >= re) continue; + if (bs > cur) free.push([cur, bs]); + if (be > cur) cur = be; + } + if (cur < re) free.push([cur, re]); + + const [sh, sm] = workHours.start.split(':').map(Number); + const [eh, em] = workHours.end.split(':').map(Number); + const windows = []; + for (let d = rs.startOf('day'); d < re; d = d.plus({ days: 1 })) { + const ws = d.plus({ hours: sh, minutes: sm }); + let we = d.plus({ hours: eh, minutes: em }); + if (we <= ws) we = we.plus({ days: 1 }); + const s = ws > rs ? ws : rs; + const e = we < re ? we : re; + if (s < e) windows.push([s, e]); + } + + const dur = { minutes: durationMinutes }; + const iso = (d) => d.toISO({ suppressMilliseconds: true }); + const slots = []; + for (const [fs, fe] of free) { + for (const [ws, we] of windows) { + if (we <= fs) continue; + if (ws >= fe) break; + let t = fs > ws ? fs : ws; + const end = fe < we ? fe : we; + while (true) { + const n = t.plus(dur); + if (n > end) break; + slots.push({ start: iso(t), end: iso(n) }); + t = n; + } + } + } + return slots; +} +export default findAvailableSlots; +// Generation time: 113.083s +// Result: PASS \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/moonshotai_kimi-k3 EFF_medium.js b/tests/9_stream_visualizer/outputs/moonshotai_kimi-k3 EFF_medium.js new file mode 100644 index 0000000..04dc8cc --- /dev/null +++ b/tests/9_stream_visualizer/outputs/moonshotai_kimi-k3 EFF_medium.js @@ -0,0 +1,27 @@ +async function createStreamVisualizer(asyncIterable, { maxPoints, alpha, width, height, yDomain }) { + const { scaleLinear, line } = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm"); + const data = []; + let ema; + + for await (const { timestamp, value } of asyncIterable) { + ema = data.length ? alpha * value + (1 - alpha) * ema : value; + 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: 48.702s +// Result: PASS \ No newline at end of file