Skip to content

Commit 578645a

Browse files
feat(2018 day-13): solution for day 13 part 2
1 parent 02311a9 commit 578645a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

2018/day-13/solution.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ const init = (data) => {
1616

1717
// Execute again, this time, removing crashed carts instead of stopping
1818
const track2 = new Track(data, { removeCrashedCarts: true })
19-
while (track2.carts.filter((c) => c.ghost !== true).length > 1 && track2.frame < 10) {
19+
while (track2.carts.length > 1) {
2020
track2.advance()
2121
}
2222

23-
console.log(`Only one cart remaining at frame ${track2.frame}`)
2423
// console.log(track2.display())
25-
const remaining = track2.carts.find((c) => c.ghost !== true)
24+
const remaining = track2.carts[0]
25+
// console.log(`${remaining.length} cart(s) of ${track2.carts.length} remaining at frame ${track2.frame}`)
26+
// console.log(remaining)
2627
const answer2 = [remaining.x, remaining.y]
2728

2829
console.log(`-- Part 1 --`)

0 commit comments

Comments
 (0)