Mercurial > repos > other > adventofcode2023
annotate day3.txt @ 27:6b58ddfaed38
Add Day 18 part 1 solution using line crossing
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 02 Jan 2024 16:04:33 +0000 |
parents | 1e16a25a9553 |
children |
rev | line source |
---|---|
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
1 --- Day 3: Gear Ratios --- |
2 | 2 |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
3 A part is missing from a system. If you can add up all the part numbers in the schematic, it should be easy to work out which part is missing. |
2 | 4 |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
5 The schematic (your puzzle input) consists of a visual representation of the system. There are lots of numbers and symbols you don't really understand, but apparently any number adjacent to a symbol, even diagonally, is a "part number" and should be included in your sum. (Periods (.) do not count as a symbol.) |
2 | 6 |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
7 Here is an example schematic: |
2 | 8 |
9 467..114.. | |
10 ...*...... | |
11 ..35..633. | |
12 ......#... | |
13 617*...... | |
14 .....+.58. | |
15 ..592..... | |
16 ......755. | |
17 ...$.*.... | |
18 .664.598.. | |
19 | |
20 In this schematic, two numbers are not part numbers because they are not adjacent to a symbol: 114 (top right) and 58 (middle right). Every other number is adjacent to a symbol and so is a part number; their sum is 4361. | |
21 | |
19
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
22 Of course, the actual schematic is much larger. What is the sum of all of the part numbers in the schematic? |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
23 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
24 --- Part Two --- |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
25 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
26 The missing part wasn't the only issue - one of the gears in the schematic is wrong. A gear is any * symbol that is adjacent to exactly two part numbers. Its gear ratio is the result of multiplying those two numbers together. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
27 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
28 This time, you need to find the gear ratio of every gear and add them all up to figure out which gear needs to be replaced. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
29 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
30 Consider the same schematic again: |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
31 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
32 467..114.. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
33 ...*...... |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
34 ..35..633. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
35 ......#... |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
36 617*...... |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
37 .....+.58. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
38 ..592..... |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
39 ......755. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
40 ...$.*.... |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
41 .664.598.. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
42 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
43 In this schematic, there are two gears. The first is in the top left; it has part numbers 467 and 35, so its gear ratio is 16345. The second gear is in the lower right; its gear ratio is 451490. (The * adjacent to 617 is not a gear because it is only adjacent to one part number.) Adding up all of the gear ratios produces 467835. |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
44 |
1e16a25a9553
Strip down the text to just the puzzle, not the fluff
IBBoard <dev@ibboard.co.uk>
parents:
2
diff
changeset
|
45 What is the sum of all of the gear ratios in your schematic? |