Docs: Update Gemini benchmark results

This commit is contained in:
github-actions[bot]
2025-11-18 22:04:41 +00:00
parent 31a18dd4ee
commit 33b8150958
220 changed files with 3259 additions and 1494 deletions

View File

@@ -1,15 +1,25 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const m = (l) => l.reduce((h, p) => {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
return h
}, [])
const l = m(s)
const u = m([...s].reverse())
return [...l.slice(0, -1), ...u.slice(0, -1)]
}
const findConvexHull = async (P) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const U = _.uniqWith(P, _.isEqual);
if (U.length < 3) return U;
const S = _.sortBy(U, ['x', 'y']);
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const build = (list) => {
const h = [];
list.forEach(p => {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
});
return h;
};
const l = build(S);
const u = build([...S].reverse());
return [...l.slice(0, -1), ...u.slice(0, -1)];
};
export default findConvexHull;

View File

@@ -1,13 +1,19 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
if (s.length < 3) return s;
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const f = (h, p) => {
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
return h;
};
return [...s.reduce(f, []).slice(0, -1), ...s.reduceRight(f, []).slice(0, -1)];
};
const { default: _ } = await import('https://esm.sh/lodash')
const u = _.uniqWith(pts, _.isEqual)
if (u.length < 3) return u
const s = _.sortBy(u, ['x', 'y'])
const cp = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const scan = (lst) => {
const h = []
lst.forEach(p => {
while (h.length >= 2 && cp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
})
return h
}
const l = scan(s)
const uH = scan(s.reverse())
return _.concat(l.slice(0, -1), uH.slice(0, -1))
}
export default findConvexHull;

View File

@@ -1,27 +1,18 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
if (!Array.isArray(pts)) throw new Error('Input must be an array');
const u = _.uniqWith(pts, _.isEqual);
if (u.length < 3) return u;
const s = _.sortBy(u, ['x', 'y']);
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const h = [];
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const h = [], x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
for (const p of s) {
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
}
const t = h.length + 1;
const t = h.length + 1
for (let i = s.length - 2; i >= 0; i--) {
const p = s[i];
while (h.length >= t && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop()
h.push(s[i])
}
h.pop();
return h;
};
h.pop()
return h
}
export default findConvexHull;

View File

@@ -1,24 +1,29 @@
const findConvexHull = async (pts) => {
const findConvexHull = async points => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const cross = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const build = (list) => {
const h = []
for (const p of list) {
while (h.length >= 2 && cross(h[h.length - 1], p, h[h.length - 2]) <= 0) h.pop()
h.push(p)
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
if (sorted.length < 3) return sorted
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const hull = []
for (const p of sorted) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop()
}
return h
hull.push(p)
}
const l = build(s)
const u = build([...s].reverse())
l.pop()
u.pop()
return [...l, ...u]
const lowerLen = hull.length + 1
for (let i = sorted.length - 2; i >= 0; i--) {
const p = sorted[i]
while (hull.length >= lowerLen && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop()
}
hull.push(p)
}
hull.pop()
return hull
}
export default findConvexHull;

View File

@@ -1,16 +1,24 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const u = _.uniqWith(pts, _.isEqual)
if (u.length < 3) return u
const s = _.sortBy(u, ['x', 'y'])
const cp = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const scan = (lst) => lst.reduce((h, p) => {
while (h.length >= 2 && cp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
return h
}, [])
const l = scan(s)
const up = scan([...s].reverse())
return [...l.slice(0, -1), ...up.slice(0, -1)]
}
const findConvexHull = async (p) => {
const { default: _ } = await import('https://cdn.skypack.dev/lodash');
const s = _.sortBy(_.uniqWith(p, _.isEqual), ['x', 'y']);
if (s.length < 3) return s;
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const h = [];
for (const i of s) {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], i) <= 0) h.pop();
h.push(i);
}
const t = h.length + 1;
for (let i = s.length - 2; i >= 0; i--) {
const k = s[i];
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], k) <= 0) h.pop();
h.push(k);
}
h.pop();
return h;
};
export default findConvexHull;

View File

@@ -1,17 +1,21 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const k = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const m = (v) => {
const h = []
for (const p of v) {
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
}
return h
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
if (s.length < 3) return s;
const h = [], x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
for (let i = 0; i < s.length; i++) {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
h.push(s[i]);
}
const l = m(s), u = m(s.reverse())
return l.slice(0, -1).concat(u.slice(0, -1))
}
for (let i = s.length - 2, t = h.length + 1; i >= 0; i--) {
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
h.push(s[i]);
}
h.pop();
return h;
};
export default findConvexHull;

View File

@@ -1,22 +1,23 @@
const findConvexHull = async points => {
const { default: _ } = await import('https://esm.sh/lodash')
const s = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const findConvexHull = async (points) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
const h = [], x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
if (sorted.length < 3) return sorted;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
s.forEach(p => {
while (h.length >= 2 && x(h.at(-2), h.at(-1), p) <= 0) h.pop()
h.push(p)
})
const t = h.length + 1
for (let i = s.length - 2; i >= 0; i--) {
while (h.length >= t && x(h.at(-2), h.at(-1), s[i]) <= 0) h.pop()
h.push(s[i])
}
h.pop()
return h
}
const buildHull = (list) => {
const hull = [];
list.forEach(p => {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) hull.pop();
hull.push(p);
});
return hull;
};
const lower = buildHull(sorted);
const upper = buildHull([...sorted].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
};
export default findConvexHull;

View File

@@ -1,24 +1,19 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const { default: _ } = await import('https://esm.sh/lodash@4');
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
if (s.length < 3) return s;
const k = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const add = (h, p) => {
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
};
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const h = [];
for (let i = 0; i < s.length; i++) {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
h.push(s[i]);
}
const t = h.length + 1;
for (let i = s.length - 2; i >= 0; i--) {
while (h.length >= t && cross(h[h.length - 2], h[h.length - 1], s[i]) <= 0) h.pop();
h.push(s[i]);
}
h.pop();
return h;
const l = [], u = [];
s.forEach(p => add(l, p));
for (let i = s.length - 1; i >= 0; i--) add(u, s[i]);
l.pop(); u.pop();
return [...l, ...u];
};
export default findConvexHull;

View File

@@ -1,23 +1,18 @@
const findConvexHull = async (pts) => {
if (!pts?.length || pts.length < 3) return pts || [];
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y']);
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const scan = (list) => {
const h = [];
for (const p of list) {
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
const x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const scan = (arr, h = []) => {
for (const p of arr) {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
}
return h;
};
return h
}
const l = scan(s);
const u = scan(s.reverse());
return [...l.slice(0, -1), ...u.slice(0, -1)];
};
const l = scan(s), u = scan([...s].reverse())
return [...l.slice(0, -1), ...u.slice(0, -1)]
}
export default findConvexHull;

View File

@@ -1,22 +1,17 @@
const findConvexHull = async (points) => {
const findConvexHull = async points => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
if (P.length < 3) return P
const xp = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const scan = (arr) => {
const h = []
for (const p of arr) {
while (h.length >= 2 && xp(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
const s = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const x = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const scan = (arr, h = []) => {
arr.forEach(p => {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
}
})
return h
}
const l = scan(P)
const u = scan(P.reverse())
return [...l.slice(0, -1), ...u.slice(0, -1)]
const l = scan(s)
const u = scan([...s].reverse())
return l.slice(0, -1).concat(u.slice(0, -1))
}
export default findConvexHull;

View File

@@ -0,0 +1,17 @@
const findConvexHull = async points => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const p = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y'])
if (p.length < 3) return p
const h = [], x = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
for (let i = 0; i < p.length; i++) {
while (h.length >= 2 && x(h[h.length - 2], h[h.length - 1], p[i]) <= 0) h.pop()
h.push(p[i])
}
for (let i = p.length - 2, t = h.length + 1; i >= 0; i--) {
while (h.length >= t && x(h[h.length - 2], h[h.length - 1], p[i]) <= 0) h.pop()
h.push(p[i])
}
h.pop()
return h
}
export default findConvexHull;

View File

@@ -0,0 +1,28 @@
export const findConvexHull = async (points) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (P.length < 3) return P;
const cross = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const buildChain = (nodes) => {
const hull = [];
for (const p of nodes) {
while (hull.length >= 2 && cross(hull[hull.length - 1], p, hull[hull.length - 2]) <= 0) {
hull.pop();
}
hull.push(p);
}
return hull;
};
const lower = buildChain(P);
const upper = buildChain([...P].reverse());
lower.pop();
upper.pop();
return [...lower, ...upper];
};
export default findConvexHull;

View File

@@ -0,0 +1,22 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const k = (a, b, o) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
const build = (list) => {
const stack = []
for (const p of list) {
while (stack.length > 1 && k(stack[stack.length - 1], p, stack[stack.length - 2]) <= 0) {
stack.pop()
}
stack.push(p)
}
return stack
}
const l = build(s)
const u = build([...s].reverse())
return [...l.slice(0, -1), ...u.slice(0, -1)]
}
export default findConvexHull;

View File

@@ -0,0 +1,23 @@
const findConvexHull = async (rawPoints) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const pts = _.sortBy(_.uniqWith(rawPoints, _.isEqual), ['x', 'y'])
if (pts.length < 3) return pts
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const build = (list) => {
const h = []
list.forEach(p => {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
})
return h
}
const lower = build(pts)
const upper = build([...pts].reverse())
lower.pop(), upper.pop()
return [...lower, ...upper]
}
export default findConvexHull;

View File

@@ -0,0 +1,23 @@
export const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')
const S = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (S.length < 3) return S
const cross = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const chain = (list) => {
const h = []
for (const p of list) {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
}
return h
}
const l = chain(S)
const u = chain([...S].reverse())
l.pop()
u.pop()
return l.concat(u)
}
export default findConvexHull;

View File

@@ -0,0 +1,19 @@
const findConvexHull = async (points) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
const sorted = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (sorted.length < 3) return sorted;
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const scan = (list) => list.reduce((h, p) => {
while (h.length > 1 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
return h.push(p), h;
}, []);
const lower = scan(sorted);
const upper = scan([...sorted].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
};
export default findConvexHull;

View File

@@ -0,0 +1,18 @@
const findConvexHull = async (pts) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash-es@4.17.21/+esm')
const s = _.sortBy(_.uniqWith(pts, _.isEqual), ['x', 'y'])
if (s.length < 3) return s
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x)
const f = (h, p) => {
while (h.length >= 2 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop()
h.push(p)
return h
}
const l = _.reduce(s, f, [])
const u = _.reduceRight(s, f, [])
return [..._.dropRight(l), ..._.dropRight(u)]
}
export default findConvexHull;

View File

@@ -0,0 +1,17 @@
const findConvexHull = async (points) => {
const { default: _ } = await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm');
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 chain = (list) => {
const h = [];
for (const p of list) {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
}
return h;
};
const lower = chain(pts), upper = chain([...pts].reverse());
return [...lower.slice(0, -1), ...upper.slice(0, -1)];
};
export default findConvexHull;

View File

@@ -1,23 +1,31 @@
const findConvexHull = async (points) => {
if (!Array.isArray(points)) throw new Error('Input must be an array');
const { default: _ } = await import('https://esm.sh/lodash');
const P = _.sortBy(_.uniqWith(points, _.isEqual), ['x', 'y']);
if (P.length < 3) return P;
const uniq = _.uniqWith(points, _.isEqual);
if (uniq.length < 3) return uniq;
const sorted = _.sortBy(uniq, ['x', 'y']);
const cross = (o, a, b) => (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
const h = [];
const build = (list) => {
const hull = [];
for (const p of list) {
while (hull.length >= 2 && cross(hull[hull.length - 2], hull[hull.length - 1], p) <= 0) {
hull.pop();
}
hull.push(p);
}
return hull;
};
for (const p of P) {
while (h.length >= 2 && cross(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
}
const t = h.length + 1;
for (let i = P.length - 2; i >= 0; i--) {
while (h.length >= t && cross(h[h.length - 2], h[h.length - 1], P[i]) <= 0) h.pop();
h.push(P[i]);
}
h.pop();
return h;
const lower = build(sorted);
const upper = build([...sorted].reverse());
lower.pop();
upper.pop();
return [...lower, ...upper];
};
export default findConvexHull;

View File

@@ -0,0 +1,18 @@
const findConvexHull = async (pts) => {
const _ = (await import('https://cdn.jsdelivr.net/npm/lodash@4.17.21/+esm')).default;
const u = _.uniqWith(pts, _.isEqual);
if (u.length < 3) return u;
const s = _.sortBy(u, ['x', 'y']);
const k = (a, b, c) => (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
const b = (list, h = []) => {
for (const p of list) {
while (h.length > 1 && k(h[h.length - 2], h[h.length - 1], p) <= 0) h.pop();
h.push(p);
}
return h;
};
const l = b(s);
const r = b(s.reverse());
return l.slice(0, -1).concat(r.slice(0, -1));
};
export default findConvexHull;