mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-07-18 05:45:46 +00:00
Docs: Update benchmark for moonshotai/kimi-k3 EFF:medium
This commit is contained in:
31
tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
31
tests/2_convex_hull/outputs/moonshotai_kimi-k3 EFF_medium.js
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user