mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 11:21:00 +00:00
Docs: Update benchmark for openrouter/pony-alpha
This commit is contained in:
28
tests/2_convex_hull/outputs/openrouter_pony-alpha.js
Normal file
28
tests/2_convex_hull/outputs/openrouter_pony-alpha.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const findConvexHull = async points => {
|
||||
const _ = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/lodash.js');
|
||||
const pts = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
|
||||
|
||||
if (pts.length < 3) return pts;
|
||||
|
||||
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
|
||||
const lower = [];
|
||||
for (const p of pts) {
|
||||
while (lower.length > 1 && cross(lower.at(-2), lower.at(-1), p) <= 0) lower.pop();
|
||||
lower.push(p);
|
||||
}
|
||||
|
||||
const upper = [];
|
||||
for (let i = pts.length - 1; i >= 0; i--) {
|
||||
const p = pts[i];
|
||||
while (upper.length > 1 && cross(upper.at(-2), upper.at(-1), p) <= 0) upper.pop();
|
||||
upper.push(p);
|
||||
}
|
||||
|
||||
lower.pop();
|
||||
upper.pop();
|
||||
return lower.concat(upper);
|
||||
};
|
||||
export default findConvexHull;
|
||||
// Generation time: 170.869s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user