diff --git a/results.json b/results.json index 78d0c65..4b8b982 100644 --- a/results.json +++ b/results.json @@ -388,5 +388,18 @@ "7_scheduler": 13.963300305999997, "8_json_validator": 3.6207129579999964, "9_stream_visualizer": 4.672214089000001 + }, + "openrouter/bert-nebulon-alpha": { + "10_scrypt_hash": 8.55691055, + "11_geospatial": 7.062121927999999, + "1_dijkstra": 11.829055708, + "2_convex_hull": 18.499725369, + "3_lis": 4.786422595999997, + "4_determinant": 8.771500180000002, + "5_markdown_parser": 13.436161649, + "6_csv_processor": 21.607565694999998, + "7_scheduler": 22.426437961999998, + "8_json_validator": 12.943359998, + "9_stream_visualizer": 12.601481400000004 } } \ No newline at end of file diff --git a/tests/10_scrypt_hash/outputs/openrouter_bert-nebulon-alpha.js b/tests/10_scrypt_hash/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..f35dd96 --- /dev/null +++ b/tests/10_scrypt_hash/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,12 @@ +const hashPassword = async (password, salt) => { + const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.min.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; \ No newline at end of file diff --git a/tests/11_geospatial/outputs/openrouter_bert-nebulon-alpha.js b/tests/11_geospatial/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..86a58ae --- /dev/null +++ b/tests/11_geospatial/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,16 @@ +export const analyzeGPS = async (readings, boundary) => { + const { default: turf } = await import('https://unpkg.com/@turf/turf@6/turf.min.js') + + const inside = readings.filter(({ loc }) => + turf.booleanPointInPolygon(turf.point(loc), boundary, { ignoreBoundary: false }) + ) + + if (inside.length < 2) return 0 + + const sorted = inside.sort((a, b) => a.ts - b.ts) + const line = turf.lineString(sorted.map(({ loc }) => loc)) + const length = turf.length(line, { units: 'kilometers' }) + + return Math.round(length * 100) / 100 +} +export default analyzeGPS; \ No newline at end of file diff --git a/tests/1_dijkstra/outputs/openrouter_bert-nebulon-alpha.js b/tests/1_dijkstra/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..55b978c --- /dev/null +++ b/tests/1_dijkstra/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,37 @@ +const findShortestPath = async (graph, start, end) => { + const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@1.0.0/+esm') + + if (!graph[start] || !graph[end]) return Infinity + + const distances = Object.keys(graph).reduce((acc, node) => { + acc[node] = node === start ? 0 : Infinity + return acc + }, {}) + + const pq = new PriorityQueue({ comparator: (a, b) => a.distance - b.distance }) + pq.queue({ node: start, distance: 0 }) + + const visited = new Set() + + while (pq.length) { + const { node, distance } = pq.dequeue() + + if (node === end) return distance + if (visited.has(node)) continue + + visited.add(node) + + Object.entries(graph[node]).forEach(([neighbor, weight]) => { + if (visited.has(neighbor)) return + + const newDistance = distance + weight + if (newDistance < distances[neighbor]) { + distances[neighbor] = newDistance + pq.queue({ node: neighbor, distance: newDistance }) + } + }) + } + + return Infinity +} +export default findShortestPath; \ No newline at end of file diff --git a/tests/2_convex_hull/outputs/openrouter_bert-nebulon-alpha.js b/tests/2_convex_hull/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..c960ce2 --- /dev/null +++ b/tests/2_convex_hull/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,38 @@ +const findConvexHull = async points => { + const { sortBy, uniqWith, isEqual } = await import('https://cdn.skypack.dev/lodash') + + const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x) + + const preparePoints = pts => { + const unique = uniqWith(pts, isEqual) + return sortBy(unique, ['x', 'y']) + } + + 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) + } + + const lowerHullSize = hull.length + 1 + for (let i = pts.length - 1; i >= 0; i--) { + const p = pts[i] + while (hull.length >= lowerHullSize && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) { + hull.pop() + } + hull.push(p) + } + + hull.pop() + return hull + } + + if (points.length < 3) return [...points] + const prepared = preparePoints(points) + return buildHull(prepared) +} +export default findConvexHull; \ No newline at end of file diff --git a/tests/3_lis/outputs/openrouter_bert-nebulon-alpha.js b/tests/3_lis/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..16a433b --- /dev/null +++ b/tests/3_lis/outputs/openrouter_bert-nebulon-alpha.js @@ -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) { + const i = bisectLeft(tails, num) + tails[i] = num + } + + return tails.length +} +export default findLISLength; \ No newline at end of file diff --git a/tests/4_determinant/outputs/openrouter_bert-nebulon-alpha.js b/tests/4_determinant/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..eaa26cc --- /dev/null +++ b/tests/4_determinant/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,15 @@ +const calculateDeterminant = async matrix => { + const { create } = await import('https://cdn.jsdelivr.net/npm/mathjs@11.7.0/+esm') + const math = create() + + if (!Array.isArray(matrix) || !matrix.every(Array.isArray)) { + throw new TypeError('Input must be an array of arrays') + } + + if (matrix.length === 0 || matrix.some(row => row.length !== matrix.length)) { + throw new Error('Matrix must be square (n x n)') + } + + return math.det(matrix) +} +export default calculateDeterminant; \ No newline at end of file diff --git a/tests/5_markdown_parser/outputs/openrouter_bert-nebulon-alpha.js b/tests/5_markdown_parser/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..7f9e1c3 --- /dev/null +++ b/tests/5_markdown_parser/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,15 @@ +const parseMarkdown = async (markdown) => { + const { default: marked } = await import('https://cdn.jsdelivr.net/npm/marked@4.0.12/lib/marked.esm.js') + const { default: DOMPurify } = await import('https://cdn.jsdelivr.net/npm/dompurify@3.0.5/dist/purify.es.mjs') + + marked.setOptions({ + gfm: true, + breaks: true, + headerIds: false, + mangle: false + }) + + const html = marked.parse(markdown) + return DOMPurify.sanitize(html) +} +export default parseMarkdown; \ No newline at end of file diff --git a/tests/6_csv_processor/outputs/openrouter_bert-nebulon-alpha.js b/tests/6_csv_processor/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..5e30299 --- /dev/null +++ b/tests/6_csv_processor/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,25 @@ +const processCSV = async (csvData, config) => { + const { parse } = await import('https://cdn.skypack.dev/papaparse@5.3.0') + const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config + const { data } = parse(csvData, { header: true }) + + const filtered = data.filter(row => row[filterColumn] == filterValue) + const groups = filtered.reduce((acc, row) => { + const key = row[groupBy] + if (!acc[key]) acc[key] = [] + acc[key].push(row) + return acc + }, {}) + + return Object.entries(groups).map(([groupValue, rows]) => { + const numbers = rows.map(row => +row[aggregateColumn] || 0) + let result + + if (operation === 'sum') result = numbers.reduce((a, b) => a + b, 0) + if (operation === 'avg') result = numbers.reduce((a, b) => a + b, 0) / numbers.length + if (operation === 'count') result = numbers.length + + return { [groupBy]: groupValue, result } + }) +} +export default processCSV; \ No newline at end of file diff --git a/tests/7_scheduler/outputs/openrouter_bert-nebulon-alpha.js b/tests/7_scheduler/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..123a953 --- /dev/null +++ b/tests/7_scheduler/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,71 @@ +const findAvailableSlots = async (calendar1, calendar2, constraints) => { + const { DateTime, Interval } = await import('https://cdn.skypack.dev/luxon@3.0.1') + + const { durationMinutes, searchRange, workHours } = constraints + const workStart = DateTime.fromISO(`${searchRange.start.split('T')[0]}T${workHours.start}:00Z`) + const workEnd = DateTime.fromISO(`${searchRange.start.split('T')[0]}T${workHours.end}:00Z`) + const searchStart = DateTime.fromISO(searchRange.start) + const searchEnd = DateTime.fromISO(searchRange.end) + + const mergeCalendars = (cal1, cal2) => { + const allSlots = [...cal1, ...cal2].map(slot => ({ + start: DateTime.fromISO(slot.start), + end: DateTime.fromISO(slot.end) + })).sort((a, b) => a.start - b.start) + + return allSlots.reduce((merged, current) => { + if (merged.length === 0) return [current] + + const last = merged[merged.length - 1] + if (current.start <= last.end) { + last.end = current.end > last.end ? current.end : last.end + return merged + } + + return [...merged, current] + }, []) + } + + const mergedBusy = mergeCalendars(calendar1, calendar2) + const freeIntervals = [] + + let currentStart = searchStart + for (const busy of mergedBusy) { + if (busy.start > currentStart) { + freeIntervals.push(Interval.fromDateTimes(currentStart, busy.start)) + } + currentStart = busy.end > currentStart ? busy.end : currentStart + } + + if (currentStart < searchEnd) { + freeIntervals.push(Interval.fromDateTimes(currentStart, searchEnd)) + } + + const availableSlots = freeIntervals.flatMap(interval => { + const slots = [] + let slotStart = interval.start + + while (slotStart.plus({ minutes: durationMinutes }) <= interval.end) { + const slotEnd = slotStart.plus({ minutes: durationMinutes }) + const slotInterval = Interval.fromDateTimes(slotStart, slotEnd) + + if (slotInterval.engulfs(workStart) && slotInterval.engulfs(workEnd)) { + slots.push({ + start: slotStart.toISO(), + end: slotEnd.toISO() + }) + } + + slotStart = slotEnd + } + + return slots + }) + + return availableSlots.filter(slot => { + const slotStart = DateTime.fromISO(slot.start) + const slotEnd = DateTime.fromISO(slot.end) + return slotStart >= workStart && slotEnd <= workEnd + }) +} +export default findAvailableSlots; \ No newline at end of file diff --git a/tests/8_json_validator/outputs/openrouter_bert-nebulon-alpha.js b/tests/8_json_validator/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..801a095 --- /dev/null +++ b/tests/8_json_validator/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,36 @@ +const validateJSON = async (json, schema) => { + try { + const { default: Ajv } = await import('https://cdn.jsdelivr.net/npm/ajv@8.12.0/+esm') + const { default: addFormats } = await import('https://cdn.jsdelivr.net/npm/ajv-formats@2.1.1/+esm') + + const ajv = new Ajv({ + allErrors: true, + strict: false, + validateSchema: true + }) + + addFormats(ajv) + + const validate = ajv.compile(schema) + const valid = validate(json) + + return { + valid, + errors: valid ? [] : validate.errors.map(err => ({ + message: err.message, + instancePath: err.instancePath, + schemaPath: err.schemaPath, + params: err.params + })) + } + } catch (error) { + return { + valid: false, + errors: [{ + message: error.message, + stack: error.stack + }] + } + } +} +export default validateJSON; \ No newline at end of file diff --git a/tests/9_stream_visualizer/outputs/openrouter_bert-nebulon-alpha.js b/tests/9_stream_visualizer/outputs/openrouter_bert-nebulon-alpha.js new file mode 100644 index 0000000..98a6d2e --- /dev/null +++ b/tests/9_stream_visualizer/outputs/openrouter_bert-nebulon-alpha.js @@ -0,0 +1,41 @@ +const createStreamVisualizer = async (asyncIterable, { + maxPoints = 1000, + alpha = 0.3, + width = 800, + height = 400, + yDomain = [0, 1] +} = {}) => { + const { scaleLinear, line } = await import('https://cdn.skypack.dev/d3@7'); + const data = []; + let prevEma; + + for await (const { timestamp, value } of asyncIterable) { + const ema = prevEma === undefined + ? value + : alpha * value + (1 - alpha) * prevEma; + prevEma = ema; + + data.push({ timestamp, value, ema }); + if (data.length > maxPoints) data.shift(); + } + + if (!data.length) return { data: [], path: '' }; + + const xScale = scaleLinear() + .domain([data[0].timestamp, data[data.length - 1].timestamp]) + .range([0, width]); + + const yScale = scaleLinear() + .domain(yDomain) + .range([height, 0]); + + const pathGenerator = line() + .x(d => xScale(d.timestamp)) + .y(d => yScale(d.ema)); + + return { + data, + path: pathGenerator(data) + }; +}; +export default createStreamVisualizer; \ No newline at end of file