2025(05): pull in part 1
This commit is contained in:
45
2025/05/README.md
Normal file
45
2025/05/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Day 5: Cafeteria
|
||||||
|
|
||||||
|
[https://adventofcode.com/2025/day/5](https://adventofcode.com/2025/day/5)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
### Part One
|
||||||
|
|
||||||
|
As the forklifts break through the wall, the Elves are delighted to discover that there was a cafeteria on the other side after all.
|
||||||
|
|
||||||
|
You can hear a commotion coming from the kitchen. "At this rate, we won't have any time left to put the wreaths up in the dining hall!" Resolute in your quest, you investigate.
|
||||||
|
|
||||||
|
"If only we hadn't switched to the new inventory management system right before Christmas!" another Elf exclaims. You ask what's going on.
|
||||||
|
|
||||||
|
The Elves in the kitchen explain the situation: because of their complicated new inventory management system, they can't figure out which of their ingredients are _fresh_ and which are <span title="No, this puzzle does not take place on Gleba. Why do you ask?"><em>spoiled</em></span>. When you ask how it works, they give you a copy of their database (your puzzle input).
|
||||||
|
|
||||||
|
The database operates on _ingredient IDs_. It consists of a list of _fresh ingredient ID ranges_, a blank line, and a list of _available ingredient IDs_. For example:
|
||||||
|
|
||||||
|
3-5
|
||||||
|
10-14
|
||||||
|
16-20
|
||||||
|
12-18
|
||||||
|
|
||||||
|
1
|
||||||
|
5
|
||||||
|
8
|
||||||
|
11
|
||||||
|
17
|
||||||
|
32
|
||||||
|
|
||||||
|
|
||||||
|
The fresh ID ranges are _inclusive_: the range `3-5` means that ingredient IDs `3`, `4`, and `5` are all _fresh_. The ranges can also _overlap_; an ingredient ID is fresh if it is in _any_ range.
|
||||||
|
|
||||||
|
The Elves are trying to determine which of the _available ingredient IDs_ are _fresh_. In this example, this is done as follows:
|
||||||
|
|
||||||
|
* Ingredient ID `1` is spoiled because it does not fall into any range.
|
||||||
|
* Ingredient ID `5` is _fresh_ because it falls into range `3-5`.
|
||||||
|
* Ingredient ID `8` is spoiled.
|
||||||
|
* Ingredient ID `11` is _fresh_ because it falls into range `10-14`.
|
||||||
|
* Ingredient ID `17` is _fresh_ because it falls into range `16-20` as well as range `12-18`.
|
||||||
|
* Ingredient ID `32` is spoiled.
|
||||||
|
|
||||||
|
So, in this example, _`3`_ of the available ingredient IDs are fresh.
|
||||||
|
|
||||||
|
Process the database file from the new inventory management system. _How many of the available ingredient IDs are fresh?_
|
||||||
1180
2025/05/input
Normal file
1180
2025/05/input
Normal file
File diff suppressed because it is too large
Load Diff
11
2025/05/testinput
Normal file
11
2025/05/testinput
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
3-5
|
||||||
|
10-14
|
||||||
|
16-20
|
||||||
|
12-18
|
||||||
|
|
||||||
|
1
|
||||||
|
5
|
||||||
|
8
|
||||||
|
11
|
||||||
|
17
|
||||||
|
32
|
||||||
Reference in New Issue
Block a user