Still did it wrong :) - ope

This commit is contained in:
rain
2023-12-05 18:53:21 -06:00
parent 0452e0d727
commit c18d10b935
8 changed files with 798 additions and 4146 deletions
+25 -37
View File
@@ -1,22 +1,25 @@
[--- Day 1: Trebuchet?! ---
--------------------------
[--- Day 4: Scratchcards ---
---------------------------
Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems.
The gondola takes you up. Strangely, though, the ground doesn't seem to be coming with you; you're not climbing a mountain. As the circle of Snow Island recedes below you, an entire new landmass suddenly appears above you! The gondola carries you to the surface of the new island and lurches into the station.
You've been doing this long enough to know that to restore snow operations, you need to check all *fifty stars* by December 25th.
As you exit the gondola, the first thing you notice is that the air here is much *warmer* than it was on Snow Island. It's also quite *humid*. Is this where the water source is?
Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants *one star*. Good luck!
The next thing you notice is an Elf sitting on the floor across the station in what seems to be a pile of colorful square cards.
You try to ask why they can't just use a [weather machine](/2015/day/1) ("not powerful enough") and where they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a lot of questions") and hang on did you just say the sky ("of course, where do you think snow comes from") when you realize that the Elves are already loading you into a [trebuchet](https://en.wikipedia.org/wiki/Trebuchet) ("please hold still, we need to strap you in").
"Oh! Hello!" The Elf excitedly runs over to you. "How may I be of service?" You ask about water sources.
As they're making the final adjustments, they discover that their calibration document (your puzzle input) has been *amended* by a very young Elf who was apparently just excited to show off her art skills. Consequently, the Elves are having trouble reading the values on the document.
"I'm not sure; I just operate the gondola lift. That does sound like something we'd have, though - this is *Island Island*, after all! I bet the *gardener* would know. He's on a different island, though - er, the small kind surrounded by water, not the floating kind. We really need to come up with a better naming scheme. Tell you what: if you can help me with something quick, I'll let you *borrow my boat* and you can go visit the gardener. I got all these [scratchcards](https://en.wikipedia.org/wiki/Scratchcard) as a gift, but I can't figure out what I've won."
The newly-improved calibration document consists of lines of text; each line originally contained a specific *calibration value* that the Elves now need to recover. On each line, the calibration value can be found by combining the *first digit* and the *last digit* (in that order) to form a single *two-digit number*.
The Elf leads you over to the pile of colorful cards. There, you discover dozens of scratchcards, all with their opaque covering already scratched off. Picking one up, it looks like each card has two lists of numbers separated by a vertical bar (`|`): a list of *winning numbers* and then a list of *numbers you have*. You organize the information into a table (your puzzle input).
As far as the Elf has been able to figure out, you have to figure out which of the *numbers you have* appear in the list of *winning numbers*. The first match makes the card worth *one point* and each match after the first *doubles* the point value of that card.
For example:
@@ -24,44 +27,29 @@ For example:
```
1abc2
pqr3stu8vwx
a1b2c3d4e5f
treb7uchet
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
```
In this example, the calibration values of these four lines are `12`, `38`, `15`, and `77`. Adding these together produces `*142*`.
In the above example, card 1 has five winning numbers (`41`, `48`, `83`, `86`, and `17`) and eight numbers you have (`83`, `86`, `6`, `31`, `17`, `9`, `48`, and `53`). Of the numbers you have, four of them (`48`, `83`, `17`, and `86`) are winning numbers! That means card 1 is worth `*8*` points (1 for the first match, then doubled three times for each of the three matches after the first).
Consider your entire calibration document. *What is the sum of all of the calibration values?*
* Card 2 has two winning numbers (`32` and `61`), so it is worth `*2*` points.
* Card 3 has two winning numbers (`1` and `21`), so it is worth `*2*` points.
* Card 4 has one winning number (`84`), so it is worth `*1*` point.
* Card 5 has no winning numbers, so it is worth no points.
* Card 6 has no winning numbers, so it is worth no points.
, --- Part Two ---
----------------
Your calculation isn't quite right. It looks like some of the digits are actually *spelled out with letters*: `one`, `two`, `three`, `four`, `five`, `six`, `seven`, `eight`, and `nine` *also* count as valid "digits".
So, in this example, the Elf's pile of scratchcards is worth `*13*` points.
Equipped with this new information, you now need to find the real first and last digit on each line. For example:
```
two1nine
eightwothree
abcone2threexyz
xtwone3four
4nineeightseven2
zoneight234
7pqrstsixteen
```
In this example, the calibration values are `29`, `83`, `13`, `24`, `42`, `14`, and `76`. Adding these together produces `*281*`.
*What is the sum of all of the calibration values?*
Take a seat in the large pile of colorful cards. *How many points are they worth in total?*
]