mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-13 16:17:54 +00:00
Docs: Update benchmark for anthropic/claude-opus-4.5 TEMP:0.7
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
async function hashPassword(p, s) {
|
||||
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm')
|
||||
const e = new TextEncoder()
|
||||
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
|
||||
return [...h].map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
}
|
||||
export default hashPassword;
|
||||
@@ -0,0 +1,15 @@
|
||||
async function analyzeGPS(readings, boundary) {
|
||||
const turf = await import('https://cdn.jsdelivr.net/npm/@turf/turf@7/+esm');
|
||||
|
||||
const valid = readings
|
||||
.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, { ignoreBoundary: true }))
|
||||
.sort((a, b) => a.ts - b.ts);
|
||||
|
||||
if (valid.length < 2) return 0;
|
||||
|
||||
const line = turf.lineString(valid.map(r => r.loc));
|
||||
const len = turf.length(line, { units: 'kilometers' });
|
||||
|
||||
return Math.round(len * 100) / 100;
|
||||
}
|
||||
export default analyzeGPS;
|
||||
@@ -0,0 +1,32 @@
|
||||
async function findShortestPath(graph, start, end) {
|
||||
const { default: PriorityQueue } = await import("https://esm.run/js-priority-queue");
|
||||
|
||||
const dist = {}, visited = new Set();
|
||||
|
||||
for (let n in graph) dist[n] = Infinity;
|
||||
dist[start] = 0;
|
||||
|
||||
const pq = new PriorityQueue({ comparator: (a, b) => a[1] - b[1] });
|
||||
pq.queue([start, 0]);
|
||||
|
||||
while (pq.length) {
|
||||
const [node, d] = pq.dequeue();
|
||||
|
||||
if (visited.has(node)) continue;
|
||||
visited.add(node);
|
||||
|
||||
if (node === end) return d;
|
||||
|
||||
for (let neighbor in graph[node] || {}) {
|
||||
if (visited.has(neighbor)) continue;
|
||||
const newDist = d + graph[node][neighbor];
|
||||
if (newDist < dist[neighbor]) {
|
||||
dist[neighbor] = newDist;
|
||||
pq.queue([neighbor, newDist]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dist[end] ?? Infinity;
|
||||
}
|
||||
export default findShortestPath;
|
||||
@@ -0,0 +1,27 @@
|
||||
const findConvexHull = async (points) => {
|
||||
const _ = (await import("https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.min.js")).default;
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const unique = _.uniqWith(points, _.isEqual);
|
||||
const sorted = _.sortBy(unique, ["x", "y"]);
|
||||
|
||||
if (sorted.length < 3) return sorted;
|
||||
|
||||
const lower = [];
|
||||
for (const p of sorted) {
|
||||
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], p) <= 0)
|
||||
lower.pop();
|
||||
lower.push(p);
|
||||
}
|
||||
|
||||
const upper = [];
|
||||
for (const p of _.reverse([...sorted])) {
|
||||
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], p) <= 0)
|
||||
upper.pop();
|
||||
upper.push(p);
|
||||
}
|
||||
|
||||
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
|
||||
};
|
||||
export default findConvexHull;
|
||||
11
tests/3_lis/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js
Normal file
11
tests/3_lis/outputs/anthropic_claude-opus-4.5 TEMP_0.7.js
Normal file
@@ -0,0 +1,11 @@
|
||||
async function findLISLength(a) {
|
||||
if (!a?.length) return 0;
|
||||
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm');
|
||||
const t = [];
|
||||
for (const n of a) {
|
||||
const i = bisectLeft(t, n);
|
||||
i < t.length ? t[i] = n : t.push(n);
|
||||
}
|
||||
return t.length;
|
||||
}
|
||||
export default findLISLength;
|
||||
@@ -0,0 +1,5 @@
|
||||
async function calculateDeterminant(matrix) {
|
||||
const { det } = await import("https://esm.run/mathjs");
|
||||
return det(matrix);
|
||||
}
|
||||
export default calculateDeterminant;
|
||||
@@ -0,0 +1,5 @@
|
||||
async function parseMarkdown(t) {
|
||||
const { marked } = await import("https://esm.sh/marked@12.0.0");
|
||||
return marked.parse(t);
|
||||
}
|
||||
export default parseMarkdown;
|
||||
@@ -0,0 +1,32 @@
|
||||
async function processCSV(csv, config) {
|
||||
const { filterColumn, filterValue, groupBy, aggregateColumn, operation } = config;
|
||||
|
||||
const { default: Papa } = await import('https://cdn.jsdelivr.net/npm/papaparse@5/+esm');
|
||||
|
||||
const { data } = Papa.parse(csv, { header: true, skipEmptyLines: true });
|
||||
|
||||
const filtered = data.filter(row => row[filterColumn] == filterValue);
|
||||
|
||||
const groups = {};
|
||||
for (const row of filtered) {
|
||||
const key = row[groupBy];
|
||||
(groups[key] ??= []).push(row);
|
||||
}
|
||||
|
||||
const toNum = v => {
|
||||
const n = Number(v);
|
||||
return isNaN(n) ? 0 : n;
|
||||
};
|
||||
|
||||
const ops = {
|
||||
sum: rows => rows.reduce((s, r) => s + toNum(r[aggregateColumn]), 0),
|
||||
avg: rows => rows.length ? ops.sum(rows) / rows.length : 0,
|
||||
count: rows => rows.length
|
||||
};
|
||||
|
||||
return Object.entries(groups).map(([k, v]) => ({
|
||||
[groupBy]: k,
|
||||
result: ops[operation](v)
|
||||
}));
|
||||
}
|
||||
export default processCSV;
|
||||
@@ -0,0 +1,77 @@
|
||||
async function findAvailableSlots(calendar1, calendar2, constraints) {
|
||||
const { DateTime, Interval } = await import('https://cdn.jsdelivr.net/npm/luxon@3.4.4/+esm');
|
||||
|
||||
const { durationMinutes, searchRange, workHours } = constraints;
|
||||
const rangeStart = DateTime.fromISO(searchRange.start, { zone: 'utc' });
|
||||
const rangeEnd = DateTime.fromISO(searchRange.end, { zone: 'utc' });
|
||||
const [whStartH, whStartM] = workHours.start.split(':').map(Number);
|
||||
const [whEndH, whEndM] = workHours.end.split(':').map(Number);
|
||||
|
||||
const busyIntervals = [...calendar1, ...calendar2]
|
||||
.map(b => Interval.fromDateTimes(
|
||||
DateTime.fromISO(b.start, { zone: 'utc' }),
|
||||
DateTime.fromISO(b.end, { zone: 'utc' })
|
||||
))
|
||||
.filter(i => i.isValid)
|
||||
.sort((a, b) => a.start - b.start);
|
||||
|
||||
const merged = [];
|
||||
for (const interval of busyIntervals) {
|
||||
if (!merged.length || merged[merged.length - 1].end < interval.start) {
|
||||
merged.push(interval);
|
||||
} else {
|
||||
const last = merged.pop();
|
||||
merged.push(Interval.fromDateTimes(
|
||||
last.start,
|
||||
last.end > interval.end ? last.end : interval.end
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
const freeIntervals = [];
|
||||
let cursor = rangeStart;
|
||||
for (const busy of merged) {
|
||||
if (busy.start > cursor && busy.start <= rangeEnd) {
|
||||
freeIntervals.push(Interval.fromDateTimes(cursor, busy.start < rangeEnd ? busy.start : rangeEnd));
|
||||
}
|
||||
cursor = busy.end > cursor ? busy.end : cursor;
|
||||
}
|
||||
if (cursor < rangeEnd) {
|
||||
freeIntervals.push(Interval.fromDateTimes(cursor, rangeEnd));
|
||||
}
|
||||
|
||||
const getWorkInterval = day => {
|
||||
const start = day.set({ hour: whStartH, minute: whStartM, second: 0, millisecond: 0 });
|
||||
const end = day.set({ hour: whEndH, minute: whEndM, second: 0, millisecond: 0 });
|
||||
return start < end ? Interval.fromDateTimes(start, end) : null;
|
||||
};
|
||||
|
||||
const slots = [];
|
||||
|
||||
for (const free of freeIntervals) {
|
||||
let day = free.start.startOf('day');
|
||||
const endDay = free.end.startOf('day');
|
||||
|
||||
while (day <= endDay) {
|
||||
const workInt = getWorkInterval(day);
|
||||
if (workInt) {
|
||||
const intersection = free.intersection(workInt);
|
||||
if (intersection && intersection.length('minutes') >= durationMinutes) {
|
||||
let slotStart = intersection.start;
|
||||
while (slotStart.plus({ minutes: durationMinutes }) <= intersection.end) {
|
||||
const slotEnd = slotStart.plus({ minutes: durationMinutes });
|
||||
slots.push({
|
||||
start: slotStart.toISO({ suppressMilliseconds: true }),
|
||||
end: slotEnd.toISO({ suppressMilliseconds: true })
|
||||
});
|
||||
slotStart = slotEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
day = day.plus({ days: 1 });
|
||||
}
|
||||
}
|
||||
|
||||
return slots.sort((a, b) => a.start.localeCompare(b.start));
|
||||
}
|
||||
export default findAvailableSlots;
|
||||
@@ -0,0 +1,18 @@
|
||||
async function validateJSON(jsonObject, jsonSchema) {
|
||||
const { default: Ajv } = await import("https://esm.sh/ajv@8");
|
||||
const { default: addFormats } = await import("https://esm.sh/ajv-formats@3");
|
||||
|
||||
const ajv = new Ajv({ allErrors: true, strict: false });
|
||||
addFormats(ajv);
|
||||
|
||||
const validate = ajv.compile(jsonSchema);
|
||||
const valid = validate(jsonObject);
|
||||
|
||||
return {
|
||||
valid,
|
||||
errors: valid ? [] : validate.errors.map(e =>
|
||||
e.instancePath ? `${e.instancePath} ${e.message}` : e.message
|
||||
)
|
||||
};
|
||||
}
|
||||
export default validateJSON;
|
||||
@@ -0,0 +1,28 @@
|
||||
async function createStreamVisualizer(asyncIterable, options) {
|
||||
const { maxPoints, alpha, width, height, yDomain } = options;
|
||||
const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
|
||||
|
||||
const data = [];
|
||||
let ema = null;
|
||||
|
||||
for await (const { timestamp, value } of asyncIterable) {
|
||||
ema = ema === null ? value : alpha * value + (1 - alpha) * ema;
|
||||
data.push({ timestamp, value, ema });
|
||||
data.length > maxPoints && data.shift();
|
||||
}
|
||||
|
||||
const xScale = d3.scaleLinear()
|
||||
.domain([data[0].timestamp, data[data.length - 1].timestamp])
|
||||
.range([0, width]);
|
||||
|
||||
const yScale = d3.scaleLinear()
|
||||
.domain(yDomain)
|
||||
.range([height, 0]);
|
||||
|
||||
const path = d3.line()
|
||||
.x(d => xScale(d.timestamp))
|
||||
.y(d => yScale(d.ema))(data);
|
||||
|
||||
return { data, path };
|
||||
}
|
||||
export default createStreamVisualizer;
|
||||
Reference in New Issue
Block a user