Skip to content

Commit

Permalink
📝 Make Day 15 compliant to its own spec (#5554)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz authored Dec 20, 2024
1 parent fc25b7a commit 2339969
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions website/blog/2024-12-15-advent-of-pbt-day-15/buggy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@ export default function advent() {
return index;
},
pop: () => {
const prevLast = (last - 1 + size) % size;
const prevIndex = remapped[prevLast];
if (data[prevIndex] === undefined) {
const index = remapped[first];
if (data[index] === undefined) {
return -1;
}
data[prevIndex] = undefined;
last = prevLast;
return prevIndex;
data[index] = undefined;
first = (first + 1) % size;
return index;
},
isEmpty: () => {
return first === last;
Expand Down

0 comments on commit 2339969

Please sign in to comment.