Skip to content

NaN72dev/aoc-2024-ts

Repository files navigation

Advent of Code 2024

My really late and very janky attempt to solve Advent of Code 2024 using Typescript.

Install dependencies to run the code.

pnpm install

This repo is generated with Advent of Code Typescript Template, day 1 - 4 is imported from my own repo.

2025-01-09 (~60m)

pnpm dev 1
#> 1889772
#> 23228917

2025-01-10 (~1h30m)

Brute forcing part 2, I'm not proud of it, but it's not that bad.

pnpm dev 2
#> 660
#> 689

2025-01-13 (~30m)

Well I prompted my AI to generate the regex. Who write their own regex anyway?

pnpm dev 3
#> 174561379
#> 106921067

2025-01-14 (~60m)

The logic might be right, but the comments are probably wrong.

pnpm dev 4
#> 2567
#> 2029

2025-01-15 (~2h20m)

I was tripping on part 2 of this puzzle. It's a shame that I need hint to solve this one (solved 5m after the hint).

pnpm dev 5
#> 5129
#> 4077

2025-01-16 (~ 1h + 30m)

pnpm dev 6
#> 5131
#> 1784

2025-01-17 (~ 1h30m + 30m)

I was planning to use backtracking and spent an hour working on it but didn't get it to work. Turns out the loop I used to iterate over the equations was wrong, so I got stuck in an infinite loop, not because of my backtracking algorithm!

Then I misunderstood the calculation, thought it should be normal math, but it's not lol. The same problem goes to part 2, I though I should eliminate the || operator, but it's not the case. I just need to add a new case to the switch statement,but I was overthinking it.

Reading is really important, guys. What a shame of me.

pnpm dev 7
#> 2437272016585
#> 162987117690649

2025-01-18 (~ 1h + 30m)

I was a game developer so right after reading the puzzle I already know what to do to solve it, coordinates are just the heart of a tons of games, even with ones that doesn't seem to have a coordinate system.

I passed the test for part 1 but the answer for my input is wrong, I'm not sure why. Update: I thought that if an anti-node is overlapped with an antenna, it doesn't count, but I was wrong.

Turns out some of the ati-node is overlapped with another anti-node. I as using Set<Vector> to remove duplicates, but it doesn't work well with Vector, after stringify the vector for the Set, it works.

Btw, TIL that everyone has their own inputs for their AoC puzzles.

That's not the right answer; your answer is too low. Curiously, it's the right answer for someone else; you might be logged in to the wrong account or just unlucky. In any case, you need to be using your puzzle input.

In part 2, I missed the part that the antennas themselves are also anti-nodes, I just need to add them to the Set<string>. I have a feeling that if there is 2 antennas that doesn't generate anti-nodes within bounds, the answer will be wrong but my current answer gave me the star so I won't investigate further.

pnpm dev 8
#> 369
#> 1169

2025-01-21 (~ 30m + 20m)

pnpm dev 9
#> 6211348208140
#> 6239783302560

2025-01-21 (~ 30m + 5m)

Funnily enough, I solved part 2 before part 1.

pnpm dev 10
#> 776
#> 1657

2025-01-22 (~ 11m + 1h45m)

There is an edge case where the split numbers are the same (for example 99) which throw me off.

pnpm dev 11
#> 224529
#> 266820198587914

2025-01-23 (~ 1h + 45m)

Part 1 is somewhat bruce forcing... Currently gave up on part 2.

pnpm dev 12
#> 1396562
#>