Metadata
-
Date
-
Tagged
-
Part of series
- Advent of Code 2024 Day 1
- Advent of Code 2024 Day 2
- Advent of Code 2024 Day 3
- Advent of Code 2024 Day 4
- Advent of Code 2024 Day 5
- Advent of Code 2024 Day 6
- Advent of Code 2024 Day 7
- Advent of Code 2024 Day 8
- Advent of Code 2024 Day 9
- Advent of Code 2024 Day 10
- Advent of Code 2024 Day 11
- Advent of Code 2024 Day 12
- Advent of Code 2024 Day 13
- Advent of Code 2024 Day 14
- Advent of Code 2024 Day 15
- Advent of Code 2024 Day 16
- Advent of Code 2024 Day 17
- Advent of Code 2024 Day 18
- Advent of Code 2024 Day 19
- Advent of Code 2024 Day 20
-
Older post
-
Newer post
Advent of Code 2024 Day 11
Day 11: Plutonian Pebbles
https://adventofcode.com/2024/day/11
Another day, another familiar location.
You are in a spot with a bunch of numbered stones in a straight line.
An example input looks like this:
The input is one line. Each stone number is separated by a space.
Each time you blink, the stones change all at once according to a few rules.
Ooh, I know this one, it’s a cellular automaton, like the game of life
The rules for how the (markings on the) stones change:
- 0 becomes 1
- Even number of digit stones turn into 2 new stones:
- Left stone gets the first half of the digits
- Right stone gets the second half of the digits
- Otherwise, the number get multiplied by 2024
Parsing
Because each stone is completely independent, and stones with the same number acts in exactly the same way, I chose to work on a map of key-value pairs where a key is a stone number, and the value is the amount of stones with that number.
Oh, and this is a day again where the numbers can get large.
Helper
Implementing the rules for what happens when you blink. This helper function takes in a map of stones, and returns a new map of stones.
Part 1
The question asks how many stones there would be after blinking 25 times.
Part 2
What was this, blinking for ants?!, it needs to be at least 3 times bigger!
The question asks how many stones there would be after blinking 75 times.
- Take the part 1 code
- Change 25 to 75
- Success
Final code
To combine both parts: Looping 75 times and recording the sum at loop number 25.