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

@@ -2,6 +2,6 @@ const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => (b + 256).toString(16).slice(1)).join('')
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.js');
const e = new TextEncoder();
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('');
};
export default hashPassword;

View File

@@ -1,5 +1,5 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js');
const e = new TextEncoder();
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32);
return [...k].map(b => b.toString(16).padStart(2, '0')).join('');
};
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...h].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return Array.from(h, b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://unpkg.com/scrypt-js?module')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/scrypt.js')
const enc = new TextEncoder()
const key = await scrypt(enc.encode(pwd), enc.encode(salt), 1024, 8, 1, 32)
return [...key].map(b => (b + 256).toString(16).slice(1)).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, 0)).join('')
}
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js@3.0.1/+esm');
const e = new TextEncoder();
const h = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32);
return Array.from(h, b => b.toString(16).padStart(2, '0')).join('');
};
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
const h = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
return [...h].map(v => v.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const enc = txt => new TextEncoder().encode(txt)
const key = await scrypt(enc(pwd), enc(salt), 1024, 8, 1, 32)
return Array.from(key, b => b.toString(16).padStart(2, '0')).join('')
}
const { scrypt } = await import('https://esm.sh/scrypt-js');
const enc = new TextEncoder();
const hash = await scrypt(enc.encode(pwd), enc.encode(salt), 1024, 8, 1, 32);
return Array.from(hash, b => b.toString(16).padStart(2, '0')).join('');
};
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => (b + 256).toString(16).slice(1)).join('')
const h = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...h].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,9 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
return Array.from(
await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32),
b => b.toString(16).padStart(2, '0')
).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (password, salt) => {
const { scrypt } = await import('https://unpkg.com/scrypt-js@3.0.1/scrypt.js')
const enc = str => new TextEncoder().encode(str)
const buf = await scrypt(enc(password), enc(salt), 1024, 8, 1, 32)
return Array.from(buf, b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = new TextEncoder()
const k = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,11 @@
const hashPassword = async (password, salt) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const encoder = new TextEncoder()
const buffer = await scrypt(
encoder.encode(password),
encoder.encode(salt),
1024, 8, 1, 32
)
return [...buffer].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt: k } = await import('https://esm.sh/scrypt-js@3.0.1')
const e = t => new TextEncoder().encode(t)
const r = await k(e(p), e(s), 1024, 8, 1, 32)
return [...r].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,7 +1,7 @@
const hashPassword = async (p, s) => {
const hashPassword = async (pwd, salt) => {
const { scrypt } = await import('https://esm.sh/scrypt-js')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
const k = await scrypt(e.encode(pwd), e.encode(salt), 1024, 8, 1, 32)
return [...k].map(b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -0,0 +1,7 @@
const hashPassword = async (p, s) => {
const { scrypt } = await import('https://cdn.jsdelivr.net/npm/scrypt-js/+esm')
const e = new TextEncoder()
const k = await scrypt(e.encode(p), e.encode(s), 1024, 8, 1, 32)
return Array.from(k, b => b.toString(16).padStart(2, '0')).join('')
}
export default hashPassword;

View File

@@ -1,10 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const T = await import('https://esm.sh/@turf/turf')
const pts = readings
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const coords = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc)
.map(({ loc }) => loc);
return pts.length < 2 ? 0 : +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2)
}
return coords.length < 2 ? 0 :
Math.round(length(lineString(coords), { units: 'kilometers' }) * 100) / 100;
};
export default analyzeGPS;

View File

@@ -1,12 +1,13 @@
const analyzeGPS = async (readings, boundary) => {
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const pts = readings
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc);
const { booleanPointInPolygon, point, lineString, length } =
await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
return pts.length < 2 ? 0 :
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100;
};
const valid = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc)
return valid.length < 2 ? 0 :
Math.round(length(lineString(valid), { units: 'kilometers' }) * 100) / 100
}
export default analyzeGPS;

View File

@@ -1,14 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const T = await import('https://esm.sh/@turf/turf');
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
const pts = readings
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
.map(r => r.loc)
if (pts.length < 2) return 0;
const len = T.length(T.lineString(pts), { units: 'kilometers' });
return Math.round(len * 100) / 100;
};
return pts.length < 2 ? 0 :
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100
}
export default analyzeGPS;

View File

@@ -1,12 +1,11 @@
const analyzeGPS = async (readings, boundary) => {
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const pts = readings
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc);
return pts.length < 2 ? 0 :
return pts.length < 2 ? 0 :
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100;
};
export default analyzeGPS;

View File

@@ -1,13 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const coords = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
const t = await import('https://esm.sh/@turf/turf');
const pts = readings
.filter(({ loc }) => t.booleanPointInPolygon(t.point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc);
return coords.length < 2
? 0
: +length(lineString(coords), { units: 'kilometers' }).toFixed(2);
return pts.length < 2 ? 0 :
Math.round(t.length(t.lineString(pts), { units: 'kilometers' }) * 100) / 100;
};
export default analyzeGPS;

View File

@@ -1,10 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const t = await import('https://esm.sh/@turf/turf');
const pts = readings
.filter(r => t.booleanPointInPolygon(t.point(r.loc), boundary, { ignoreBoundary: true }))
const { booleanPointInPolygon, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
.map(r => r.loc)
return pts.length < 2 ? 0 : +t.length(t.lineString(pts), { units: 'kilometers' }).toFixed(2);
};
return path.length < 2 ? 0 :
Math.round(length(lineString(path), { units: 'kilometers' }) * 100) / 100
}
export default analyzeGPS;

View File

@@ -1,12 +1,9 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
const t = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const pts = readings
.filter(r => t.booleanPointInPolygon(t.point(r.loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc);
return path.length < 2 ? 0 :
Math.round(length(lineString(path), { units: 'kilometers' }) * 100) / 100;
.map(r => r.loc);
return pts.length < 2 ? 0 : +t.length(t.lineString(pts), { units: 'kilometers' }).toFixed(2);
};
export default analyzeGPS;

View File

@@ -1,10 +1,13 @@
const analyzeGPS = async (readings, boundary) => {
const T = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
const pts = readings
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary, { ignoreBoundary: true }))
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
const path = readings
.filter(r => booleanPointInPolygon(point(r.loc), boundary))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc)
return pts.length < 2 ? 0 : +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2)
return path.length < 2
? 0
: +length(lineString(path), { units: 'kilometers' }).toFixed(2)
}
export default analyzeGPS;

View File

@@ -1,12 +1,14 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const pts = readings
.filter(r => booleanPointInPolygon(point(r.loc), boundary, { ignoreBoundary: true }))
const coords = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
.map(({ loc }) => loc);
return pts.length < 2 ? 0
: +length(lineString(pts), { units: 'kilometers' }).toFixed(2);
if (coords.length < 2) return 0;
const total = length(lineString(coords), { units: 'kilometers' });
return Math.round(total * 100) / 100;
};
export default analyzeGPS;

View File

@@ -1,14 +1,11 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
const turf = await import('https://esm.sh/@turf/turf');
const coords = readings
.filter(({ loc }) => turf.booleanPointInPolygon(turf.point(loc), boundary))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc)
.map(r => r.loc);
if (path.length < 2) return 0
const dist = length(lineString(path), { units: 'kilometers' })
return Math.round(dist * 100) / 100
}
return coords.length < 2 ? 0 :
Math.round(turf.length(turf.lineString(coords), { units: 'kilometers' }) * 100) / 100;
};
export default analyzeGPS;

View File

@@ -0,0 +1,12 @@
export const analyzeGPS = async (readings, boundary) => {
const { point, booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf@6.5.0')
const coords = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc)
return coords.length < 2 ? 0 :
Math.round(length(lineString(coords), { units: 'kilometers' }) * 100) / 100
}
export default analyzeGPS;

View File

@@ -0,0 +1,11 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
return path.length < 2 ? 0 : +length(lineString(path)).toFixed(2);
};
export default analyzeGPS;

View File

@@ -0,0 +1,13 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon: inside, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
const path = readings
.filter(({ loc }) => inside(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc)
if (path.length < 2) return 0
return +length(lineString(path), { units: 'kilometers' }).toFixed(2)
}
export default analyzeGPS;

View File

@@ -0,0 +1,13 @@
const analyzeGPS = async (readings, boundary) => {
const turf = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const pts = readings
.filter(r => turf.booleanPointInPolygon(turf.point(r.loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
return pts.length < 2
? 0
: +turf.length(turf.lineString(pts), { units: 'kilometers' }).toFixed(2);
};
export default analyzeGPS;

View File

@@ -0,0 +1,9 @@
const analyzeGPS = async (data, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm')
const pts = data
.filter(d => booleanPointInPolygon(point(d.loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(d => d.loc)
return pts.length < 2 ? 0 : +length(lineString(pts)).toFixed(2)
}
export default analyzeGPS;

View File

@@ -0,0 +1,11 @@
const analyzeGPS = async (readings, boundary) => {
const { point, booleanPointInPolygon, lineString, length } = await import('https://cdn.jsdelivr.net/npm/@turf/turf/+esm');
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc);
return path.length < 2 ? 0 : +length(lineString(path)).toFixed(2);
};
export default analyzeGPS;

View File

@@ -0,0 +1,11 @@
const analyzeGPS = async (readings, boundary) => {
const { point, booleanPointInPolygon, lineString, length } = await import('https://esm.sh/@turf/turf')
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary))
.sort((a, b) => a.ts - b.ts)
.map(r => r.loc)
return path.length < 2 ? 0 : +length(lineString(path), { units: 'kilometers' }).toFixed(2)
}
export default analyzeGPS;

View File

@@ -0,0 +1,12 @@
const analyzeGPS = async (readings, boundary) => {
const T = await import('https://esm.sh/@turf/turf')
const valid = readings
.filter(r => T.booleanPointInPolygon(T.point(r.loc), boundary))
.sort((a, b) => a.ts - b.ts)
if (valid.length < 2) return 0
const line = T.lineString(valid.map(v => v.loc))
return Math.round(T.length(line) * 1e2) / 1e2
}
export default analyzeGPS;

View File

@@ -1,14 +1,13 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf')
const T = await import('https://esm.sh/@turf/turf');
const path = readings
.filter(({ loc }) => booleanPointInPolygon(point(loc), boundary, { ignoreBoundary: true }))
const pts = readings
.filter(({ loc }) => T.booleanPointInPolygon(T.point(loc), boundary, { ignoreBoundary: true }))
.sort((a, b) => a.ts - b.ts)
.map(({ loc }) => loc)
.map(r => r.loc);
if (path.length < 2) return 0
const dist = length(lineString(path), { units: 'kilometers' })
return Math.round(dist * 100) / 100
}
return pts.length < 2
? 0
: +T.length(T.lineString(pts), { units: 'kilometers' }).toFixed(2);
};
export default analyzeGPS;

View File

@@ -0,0 +1,9 @@
const analyzeGPS = async (readings, boundary) => {
const { booleanPointInPolygon, point, lineString, length } = await import('https://esm.sh/@turf/turf');
const valid = readings
.filter(r => booleanPointInPolygon(point(r.loc), boundary))
.sort((a, b) => a.ts - b.ts);
return valid.length < 2 ? 0 : +length(lineString(valid.map(r => r.loc))).toFixed(2);
};
export default analyzeGPS;

View File

@@ -1,22 +1,22 @@
const findShortestPath = async (g, s, e) => {
const { default: Q } = await import('https://esm.sh/js-priority-queue')
const q = new Q({ comparator: (a, b) => a.w - b.w })
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? 1/0)) continue
if (w > (d[n] ?? Infinity)) continue
for (let v in g[n]) {
let t = w + g[n][v]
if (t < (d[v] ?? 1/0)) {
d[v] = t
q.queue({ n: v, w: t })
let k = w + g[n][v]
if (k < (d[v] ?? Infinity)) {
d[v] = k
q.queue({ n: v, w: k })
}
}
}
return 1/0
return Infinity
}
export default findShortestPath;

View File

@@ -1,19 +1,21 @@
const findShortestPath = async (g, s, e) => {
const { default: P } = await import('https://esm.sh/js-priority-queue');
const q = new P({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 };
q.queue({ n: s, w: 0 });
const { default: Q } = await import('https://esm.sh/js-priority-queue')
const d = { [s]: 0 }, q = new Q({ comparator: (a, b) => a[1] - b[1] })
q.queue([s, 0])
while (q.length) {
const { n, w } = q.dequeue();
if (n === e) return w;
if (w > (d[n] ?? 1 / 0)) continue;
for (const k in g[n] || {}) {
const t = w + g[n][k];
if (t < (d[k] ?? 1 / 0)) {
d[k] = t;
q.queue({ n: k, w: t });
const [u, w] = q.dequeue()
if (u === e) return w
if (w > (d[u] ?? 1/0)) continue
for (let v in g[u]) {
const k = w + g[u][v]
if (k < (d[v] ?? 1/0)) {
d[v] = k
q.queue([v, k])
}
}
}
return 1 / 0;
};
return 1/0
}
export default findShortestPath;

View File

@@ -1,20 +1,25 @@
const findShortestPath = async (g, s, e) => {
const { default: P } = await import('https://esm.sh/js-priority-queue')
const q = new P({ comparator: (a, b) => a.w - b.w })
const m = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (m[n] ?? 1 / 0)) continue
for (const k in g[n] || {}) {
const t = w + g[n][k]
if (t < (m[k] ?? 1 / 0)) {
m[k] = t
q.queue({ n: k, w: t })
}
const { default: P } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm');
const q = new P({ comparator: (a, b) => a.w - b.w });
const d = { [s]: 0 };
q.queue({ n: s, w: 0 });
while (q.length) {
const { n, w } = q.dequeue();
if (n === e) return w;
if (w > (d[n] ?? 1/0)) continue;
for (let v in g[n]) {
let k = w + g[n][v];
if (k < (d[v] ?? 1/0)) {
d[v] = k;
q.queue({ n: v, w: k });
}
}
}
}
return 1 / 0
}
return 1/0;
};
export default findShortestPath;

View File

@@ -1,19 +1,18 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
const d = { [s]: 0 }, q = new PQ({ comparator: (a, b) => a.w - b.w })
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? 1 / 0)) continue
const { n: u, w } = q.dequeue()
if (u === e) return w
if (w > (d[u] ?? 1 / 0)) continue
for (const [v, cost] of Object.entries(g[n] || {})) {
const t = w + cost
if (t < (d[v] ?? 1 / 0)) {
d[v] = t
q.queue({ n: v, w: t })
for (const v in g[u]) {
const nw = w + g[u][v]
if (nw < (d[v] ?? 1 / 0)) {
d[v] = nw
q.queue({ n: v, w: nw })
}
}
}

View File

@@ -1,16 +1,17 @@
const findShortestPath = async (g, s, e) => {
const { default: Q } = await import('https://esm.sh/js-priority-queue')
const d = { [s]: 0 }, q = new Q({ comparator: (a, b) => a.w - b.w })
const { default: P } = await import('https://esm.sh/js-priority-queue')
const q = new P({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? 1 / 0)) continue
for (const [v, c] of Object.entries(g[n] || {})) {
const k = w + c
if (k < (d[v] ?? 1 / 0)) {
d[v] = k
q.queue({ n: v, w: k })
for (let k in g[n]) {
const t = w + g[n][k]
if (t < (d[k] ?? 1 / 0)) {
d[k] = t
q.queue({ n: k, w: t })
}
}
}

View File

@@ -1,24 +1,19 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }, v = new Set()
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
const q = new PQ({ comparator: (a, b) => a.w - b.w }), d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (v.has(n)) continue
v.add(n)
for (const k in g[n]) {
const t = w + g[n][k]
if (t < (d[k] ?? Infinity)) {
d[k] = t
q.queue({ n: k, w: t })
if (w > (d[n] ?? 1 / 0)) continue
for (const v in g[n]) {
const k = w + g[n][v]
if (k < (d[v] ?? 1 / 0)) {
d[v] = k
q.queue({ n: v, w: k })
}
}
}
return Infinity
return 1 / 0
}
export default findShortestPath;

View File

@@ -1,25 +1,19 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
const q = new PQ({ comparator: (a, b) => a.w - b.w });
const d = { [s]: 0 };
q.queue({ w: 0, n: s });
const { default: Q } = await import('https://esm.sh/js-priority-queue');
const q = new Q({ comparator: (a, b) => a.w - b.w }), m = { [s]: 0 };
q.queue({ n: s, w: 0 });
while (q.length) {
const { w, n } = q.dequeue();
const { n, w } = q.dequeue();
if (n === e) return w;
if (w > (d[n] ?? 1 / 0)) continue;
if (w > (m[n] ?? 1/0)) continue;
for (const v in g[n]) {
const k = w + g[n][v];
if (k < (d[v] ?? 1 / 0)) {
d[v] = k;
q.queue({ w: k, n: v });
if (k < (m[v] ?? 1/0)) {
m[v] = k;
q.queue({ n: v, w: k });
}
}
}
return 1 / 0;
return 1/0;
};
export default findShortestPath;

View File

@@ -1,19 +1,22 @@
const findShortestPath = async (g, s, e) => {
const { default: P } = await import('https://esm.sh/js-priority-queue');
const q = new P({ comparator: (a, b) => a.c - b.c }), d = { [s]: 0 };
q.queue({ n: s, c: 0 });
const { default: P } = await import('https://esm.sh/js-priority-queue')
const q = new P({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, c } = q.dequeue();
if (n === e) return c;
if (c > (d[n] ?? 1 / 0)) continue;
for (let v in g[n]) {
let k = c + g[n][v];
if (k < (d[v] ?? 1 / 0)) {
d[v] = k;
q.queue({ n: v, c: k });
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? Infinity)) continue
for (const k in g[n]) {
const c = w + g[n][k]
if (c < (d[k] ?? Infinity)) {
d[k] = c
q.queue({ n: k, w: c })
}
}
}
return 1 / 0;
};
return Infinity
}
export default findShortestPath;

View File

@@ -1,5 +1,5 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
@@ -7,15 +7,14 @@ const findShortestPath = async (g, s, e) => {
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? 1 / 0)) continue
for (const k in g[n] || {}) {
const c = w + g[n][k]
if (c < (d[k] ?? 1 / 0)) {
d[k] = c
q.queue({ n: k, w: c })
for (const [v, c] of Object.entries(g[n] || {})) {
const t = w + c
if (t < (d[v] ?? 1 / 0)) {
d[v] = t
q.queue({ n: v, w: t })
}
}
}

View File

@@ -1,25 +1,23 @@
const findShortestPath = async (graph, start, end) => {
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue/+esm')
const costs = { [start]: 0 }
const queue = new PQ({ comparator: (a, b) => a.cost - b.cost })
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const dist = { [start]: 0 }
q.queue({ n: start, w: 0 })
queue.queue({ node: start, cost: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === end) return w
if (w > (dist[n] ?? Infinity)) continue
while (queue.length) {
const { node, cost } = queue.dequeue()
if (node === end) return cost
if (cost > (costs[node] ?? Infinity)) continue
for (const [neighbor, weight] of Object.entries(graph[node] || {})) {
const nextCost = cost + weight
if (nextCost < (costs[neighbor] ?? Infinity)) {
costs[neighbor] = nextCost
queue.queue({ node: neighbor, cost: nextCost })
for (const v in graph[n]) {
const d = w + graph[n][v]
if (d < (dist[v] ?? Infinity)) {
dist[v] = d
q.queue({ n: v, w: d })
}
}
}
return Infinity
}
export default findShortestPath;

View File

@@ -0,0 +1,19 @@
const findShortestPath = async (g, s, e) => {
const { default: P } = await import('https://cdn.skypack.dev/js-priority-queue')
const d = { [s]: 0 }, q = new P({ compare: (a, b) => a.w - b.w })
q.queue({ id: s, w: 0 })
while (q.length) {
const { id, w } = q.dequeue()
if (id === e) return w
if (w > (d[id] ?? 1 / 0)) continue
for (let n in g[id]) {
const k = w + g[id][n]
if (k < (d[n] ?? 1 / 0)) {
d[n] = k
q.queue({ id: n, w: k })
}
}
}
return 1 / 0
}
export default findShortestPath;

View File

@@ -0,0 +1,22 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n: u, w: c } = q.dequeue()
if (u === e) return c
if (c > (d[u] ?? 1 / 0)) continue
for (const v in g[u] || {}) {
const k = c + g[u][v]
if (k < (d[v] ?? 1 / 0)) {
d[v] = k
q.queue({ n: v, w: k })
}
}
}
return 1 / 0
}
export default findShortestPath;

View File

@@ -0,0 +1,25 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
const q = new PQ({ comparator: (a, b) => a.d - b.d })
const D = { [s]: 0 }
q.queue({ n: s, d: 0 })
while (q.length) {
const { n, d } = q.dequeue()
if (n === e) return d
if (d > (D[n] ?? 1 / 0)) continue
for (const [v, w] of Object.entries(g[n] || {})) {
const c = d + w
if (c < (D[v] ?? 1 / 0)) {
D[v] = c
q.queue({ n: v, d: c })
}
}
}
return 1 / 0
}
export default findShortestPath;

View File

@@ -0,0 +1,23 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.w - b.w })
const d = { [s]: 0 }
q.queue({ n: s, w: 0 })
while (q.length) {
const { n, w } = q.dequeue()
if (n === e) return w
if (w > (d[n] ?? 1 / 0)) continue
for (const v in g[n] || {}) {
const k = w + g[n][v]
if (k < (d[v] ?? 1 / 0)) {
d[v] = k
q.queue({ n: v, w: k })
}
}
}
return 1 / 0
}
export default findShortestPath;

View File

@@ -0,0 +1,21 @@
const findShortestPath = async (g, s, e) => {
const { default: P } = await import('https://esm.sh/js-priority-queue');
const q = new P({ comparator: (a, b) => a.w - b.w }), m = { [s]: 0 };
q.queue({ n: s, w: 0 });
while (q.length) {
const { n, w } = q.dequeue();
if (n === e) return w;
if (w > (m[n] ?? 1 / 0)) continue;
for (const [k, v] of Object.entries(g[n] || {})) {
const t = w + v;
if (t < (m[k] ?? 1 / 0)) {
m[k] = t;
q.queue({ n: k, w: t });
}
}
}
return 1 / 0;
};
export default findShortestPath;

View File

@@ -0,0 +1,27 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue');
const q = new PQ({ compare: (a, b) => a.d - b.d });
const m = { [s]: 0 };
const v = new Set();
q.queue({ n: s, d: 0 });
while (q.length) {
const { n, d: c } = q.dequeue();
if (n === e) return c;
if (v.has(n)) continue;
v.add(n);
const adj = g[n] || {};
for (const k in adj) {
const t = c + adj[k];
if (t < (m[k] ?? Infinity)) {
m[k] = t;
q.queue({ n: k, d: t });
}
}
}
return Infinity;
};
export default findShortestPath;

View File

@@ -0,0 +1,24 @@
const findShortestPath = async (g, s, e) => {
const { default: Q } = await import('https://cdn.skypack.dev/js-priority-queue')
const q = new Q({ comparator: (a, b) => a.d - b.d })
const m = { [s]: 0 }
q.queue({ n: s, d: 0 })
while (q.length) {
const { n, d } = q.dequeue()
if (n === e) return d
if (d > (m[n] ?? 1/0)) continue
for (const v in g[n]) {
const t = d + g[n][v]
if (t < (m[v] ?? 1/0)) {
m[v] = t
q.queue({ n: v, d: t })
}
}
}
return 1/0
}
export default findShortestPath;

View File

@@ -0,0 +1,25 @@
const findShortestPath = async (graph, start, end) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue@0.1.5')
const q = new PQ({ compare: (a, b) => a.d - b.d })
const dist = { [start]: 0 }
q.queue({ n: start, d: 0 })
while (q.length) {
const { n, d } = q.dequeue()
if (n === end) return d
if (d > (dist[n] ?? Infinity)) continue
for (const [v, w] of Object.entries(graph[n] || {})) {
const t = d + w
if (t < (dist[v] ?? Infinity)) {
dist[v] = t
q.queue({ n: v, d: t })
}
}
}
return Infinity
}
export default findShortestPath;

View File

@@ -1,24 +1,25 @@
const findShortestPath = async (graph, start, end) => {
const { default: PQ } = await import('https://cdn.skypack.dev/js-priority-queue');
const queue = new PQ({ comparator: (a, b) => a.d - b.d });
const dists = { [start]: 0 }, visited = new Set();
queue.queue({ n: start, d: 0 });
const { default: PriorityQueue } = await import('https://cdn.jsdelivr.net/npm/js-priority-queue@0.1.5/+esm')
const dists = new Map([[start, 0]])
const pq = new PriorityQueue({ comparator: (a, b) => a.w - b.w })
while (queue.length) {
const { n, d } = queue.dequeue();
if (n === end) return d;
if (visited.has(n)) continue;
visited.add(n);
pq.queue({ n: start, w: 0 })
while (pq.length) {
const { n, w } = pq.dequeue()
if (n === end) return w
if (w > (dists.get(n) ?? 1 / 0)) continue
for (const [neighbor, weight] of Object.entries(graph[n] || {})) {
const newDist = d + weight;
if (newDist < (dists[neighbor] ?? Infinity)) {
dists[neighbor] = newDist;
queue.queue({ n: neighbor, d: newDist });
const newWeight = w + weight
if (newWeight < (dists.get(neighbor) ?? 1 / 0)) {
dists.set(neighbor, newWeight)
pq.queue({ n: neighbor, w: newWeight })
}
}
}
return Infinity;
};
return 1 / 0
}
export default findShortestPath;

View File

@@ -0,0 +1,25 @@
const findShortestPath = async (g, s, e) => {
const { default: PQ } = await import('https://esm.sh/js-priority-queue')
const q = new PQ({ comparator: (a, b) => a.d - b.d })
const m = { [s]: 0 }
q.queue({ n: s, d: 0 })
while (q.length) {
const { n, d } = q.dequeue()
if (n === e) return d
if (d > (m[n] ?? 1 / 0)) continue
const adj = g[n] || {}
for (const k in adj) {
const v = d + adj[k]
if (v < (m[k] ?? 1 / 0)) {
m[k] = v
q.queue({ n: k, d: v })
}
}
}
return 1 / 0
}
export default findShortestPath;

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;

View File

@@ -1,7 +1,9 @@
const findLISLength = async nums => {
const { bisectLeft } = await import('https://esm.sh/d3-array')
const findLISLength = async (nums) => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
for (const x of nums) {
tails[bisectLeft(tails, x)] = x
}
return tails.length
}
export default findLISLength;

View File

@@ -1,7 +1,7 @@
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const t = []
for (const n of a) t[b(t, n)] = n
return t.length
const findLISLength = async nums => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
return tails.length
}
export default findLISLength;

View File

@@ -1,7 +1,11 @@
const findLISLength = async nums => {
const { bisectLeft } = await import('https://esm.sh/d3-array')
const findLISLength = async (arr) => {
if (!arr?.length) return 0
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
for (const n of arr) {
const i = bisectLeft(tails, n)
i < tails.length ? tails[i] = n : tails.push(n)
}
return tails.length
}
export default findLISLength;

View File

@@ -1,5 +1,5 @@
const findLISLength = async nums => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const { bisectLeft } = await import('https://esm.sh/d3-array')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
return tails.length

View File

@@ -1,7 +1,7 @@
const findLISLength = async (nums) => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const x of nums) tails[bisectLeft(tails, x)] = x
return tails.length
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
const t = []
for (const n of a) t[b(t, n)] = n
return t.length
}
export default findLISLength;

View File

@@ -1,11 +1,7 @@
const findLISLength = async (nums) => {
const findLISLength = async nums => {
const { bisectLeft } = await import('https://esm.sh/d3-array')
const tails = []
for (const x of nums) {
tails[bisectLeft(tails, x)] = x
}
for (const n of nums) tails[bisectLeft(tails, n)] = n
return tails.length
}
export default findLISLength;

View File

@@ -1,9 +1,7 @@
const findLISLength = async n => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const t = []
for (const x of n) {
t[b(t, x)] = x
}
return t.length
const findLISLength = async nums => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
return tails.length
}
export default findLISLength;

View File

@@ -1,7 +1,7 @@
const findLISLength = async nums => {
const { bisectLeft: search } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[search(tails, n)] = n
return tails.length
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
const t = []
for (const n of a) t[b(t, n)] = n
return t.length
}
export default findLISLength;

View File

@@ -1,7 +1,7 @@
const findLISLength = async n => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const t = []
for (const x of n) t[b(t, x)] = x
return t.length
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
const q = []
for (const n of a) q[b(q, n)] = n
return q.length
}
export default findLISLength;

View File

@@ -1,7 +1,10 @@
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
async function findLISLength(a) {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array/+esm')
const t = []
for (const n of a) t[b(t, n)] = n
for (const n of a) {
const i = b(t, n)
i < t.length ? t[i] = n : t.push(n)
}
return t.length
}
export default findLISLength;

View File

@@ -0,0 +1,7 @@
const findLISLength = async nums => {
const { bisectLeft } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const tails = []
for (const n of nums) tails[bisectLeft(tails, n)] = n
return tails.length
}
export default findLISLength;

View File

@@ -0,0 +1,10 @@
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://esm.sh/d3-array')
const t = []
for (const v of a) {
const i = b(t, v)
i < t.length ? t[i] = v : t.push(v)
}
return t.length
}
export default findLISLength;

View File

@@ -0,0 +1,10 @@
const findLISLength = async (n) => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const t = []
for (const v of n) {
const i = b(t, v)
i < t.length ? t[i] = v : t.push(v)
}
return t.length
}
export default findLISLength;

View File

@@ -0,0 +1,7 @@
const findLISLength = async (nums) => {
const { bisectLeft: b } = await import('https://esm.sh/d3-array@3');
const t = [];
for (const n of nums) t[b(t, n)] = n;
return t.length;
};
export default findLISLength;

View File

@@ -0,0 +1,9 @@
const findLISLength = async (nums) => {
const { bisectLeft } = await import('https://esm.sh/d3-array@3');
const tails = [];
for (const n of nums) {
tails[bisectLeft(tails, n)] = n;
}
return tails.length;
};
export default findLISLength;

View File

@@ -0,0 +1,7 @@
const findLISLength = async nums => {
const { bisectLeft: search } = await import('https://esm.sh/d3-array')
const tails = []
for (const n of nums) tails[search(tails, n)] = n
return tails.length
}
export default findLISLength;

View File

@@ -0,0 +1,7 @@
const findLISLength = async (n) => {
const { bisectLeft: b } = await import('https://esm.run/d3-array')
const t = []
for (const v of n) t[b(t, v)] = v
return t.length
}
export default findLISLength;

View File

@@ -0,0 +1,9 @@
const findLISLength = async (nums) => {
const { bisectLeft } = await import('https://esm.sh/d3-array');
const tails = [];
for (const n of nums) {
tails[bisectLeft(tails, n)] = n;
}
return tails.length;
};
export default findLISLength;

View File

@@ -1,9 +1,7 @@
const findLISLength = async nums => {
const { bisectLeft } = await import('https://esm.sh/d3-array')
const sub = []
for (const n of nums) {
sub[bisectLeft(sub, n)] = n
}
return sub.length
const findLISLength = async a => {
const { bisectLeft: b } = await import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
const t = []
for (const n of a) t[b(t, n)] = n
return t.length
}
export default findLISLength;

View File

@@ -0,0 +1,9 @@
const findLISLength = async (nums) => {
const { bisectLeft } = await import("https://cdn.jsdelivr.net/npm/d3-array@3/+esm");
const tails = [];
for (const n of nums) {
tails[bisectLeft(tails, n)] = n;
}
return tails.length;
};
export default findLISLength;

Some files were not shown because too many files have changed in this diff Show More