mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-03-17 11:21:00 +00:00
Refactor: Remove stale benchmark outputs
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
async function findConvexHull(points) {
|
||||
if (!Array.isArray(points)) throw new TypeError("points must be an array")
|
||||
|
||||
const { default: _ } = await import("https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm")
|
||||
const eq = (a, b) => a.x === b.x && a.y === b.y
|
||||
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
|
||||
|
||||
const pts = _.uniqWith(_.sortBy(points, ["x", "y"]), eq)
|
||||
if (pts.length < 2) return pts.slice()
|
||||
|
||||
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; 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: 15.278s
|
||||
// Result: PASS
|
||||
@@ -1,21 +0,0 @@
|
||||
async function findConvexHull(p){
|
||||
const _=await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm');
|
||||
const s=_.sortBy(_.uniqBy(p,q=>q.x+','+q.y),['x','y']);
|
||||
const c=(o,a,b)=> (a.x-o.x)*(b.y-o.y)-(a.y-o.y)*(b.x-o.x);
|
||||
const L=[];
|
||||
for(const q of s){
|
||||
while(L.length>1 && c(L[L.length-2],L[L.length-1],q)<=0) L.pop();
|
||||
L.push(q);
|
||||
}
|
||||
const U=[];
|
||||
for(let i=s.length-1;i>=0;i--){
|
||||
const q=s[i];
|
||||
while(U.length>1 && c(U[U.length-2],U[U.length-1],q)<=0) U.pop();
|
||||
U.push(q);
|
||||
}
|
||||
U.pop();L.pop();
|
||||
return L.concat(U);
|
||||
}
|
||||
export default findConvexHull;
|
||||
// Generation time: 1.623s
|
||||
// Result: PASS
|
||||
@@ -1,28 +0,0 @@
|
||||
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