Skip to content

Commit

Permalink
Add day 17 of year 2024 🤶
Browse files Browse the repository at this point in the history
  • Loading branch information
letelete committed Dec 17, 2024
1 parent 4647b41 commit 8985b2b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
4 changes: 2 additions & 2 deletions 2024/days/day-17/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
9 changes: 0 additions & 9 deletions 2024/days/day-17/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
};

Expand Down

0 comments on commit 8985b2b

Please sign in to comment.