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