diff --git a/2024/days/day-17/README.md b/2024/days/day-17/README.md index e816bbe..d30595d 100644 --- a/2024/days/day-17/README.md +++ b/2024/days/day-17/README.md @@ -10,5 +10,5 @@ Memory: 18.00 GB | part | time (~) | μs | | ---- | -------- | ------------------ | -| 1 | 6.09ms | 6.088292000000003 | -| 2 | 2.35ms | 2.3469580000000008 | +| 1 | 11.14ms | 11.139207999999996 | +| 2 | 5.96ms | 5.964500000000001 | diff --git a/2024/days/day-17/main.js b/2024/days/day-17/main.js index 95d562b..2f8568a 100644 --- a/2024/days/day-17/main.js +++ b/2024/days/day-17/main.js @@ -80,14 +80,7 @@ function Computer({ reg: { a, b, c }, verbose }) { } function findMinAToOutputSelf({ reg: { b, c }, program }) { - const cache = new Map(); - const lookup = (lowerBound, ptr) => { - const hash = `${lowerBound},${ptr}`; - if (cache.has(hash)) { - return cache.get(hash); - } - if (ptr < 0) { return lowerBound; } @@ -99,13 +92,11 @@ function findMinAToOutputSelf({ reg: { b, c }, program }) { if (cmp.state.out[0] === program[ptr]) { const match = lookup(a, ptr - 1); if (match >= 0) { - cache.set(hash, match); return match; } } } - cache.set(hash, -1); return -1; };