mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-06-28 04:12:13 +00:00
Docs: Update benchmark for moonshotai/kimi-k2.7-code
This commit is contained in:
22
tests/1_dijkstra/outputs/moonshotai_kimi-k2.7-code.js
Normal file
22
tests/1_dijkstra/outputs/moonshotai_kimi-k2.7-code.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const findShortestPath = async (graph, start, end) => {
|
||||
const {default: PQ} = await import('https://esm.sh/js-priority-queue');
|
||||
const dist = new Map([[start, 0]]);
|
||||
const pq = new PQ({comparator: (a, b) => a[1] - b[1]});
|
||||
pq.queue([start, 0]);
|
||||
while (pq.length) {
|
||||
const [u, d] = pq.dequeue();
|
||||
if (u === end) return d;
|
||||
if (d > (dist.get(u) ?? Infinity)) continue;
|
||||
for (const [v, w] of Object.entries(graph[u] || {})) {
|
||||
const nd = d + w;
|
||||
if (nd < (dist.get(v) ?? Infinity)) {
|
||||
dist.set(v, nd);
|
||||
pq.queue([v, nd]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Infinity;
|
||||
};
|
||||
export default findShortestPath;
|
||||
// Generation time: 42.886s
|
||||
// Result: PASS
|
||||
Reference in New Issue
Block a user