adventofcode/2023/day18/problem

169 lines
5.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[1]Advent of Code
• [2][About]
• [3][Events]
• [4][Shop]
• [5][Settings]
• [6][Log Out]
br0xen [7](AoC++) 36*
   0xffff&[8]2023
• [9][Calendar]
• [10][AoC++]
• [11][Sponsors]
• [12][Leaderboard]
• [13][Stats]
Our [14]sponsors help make Advent of Code possible:
[15]Best Buy - Our purpose is to enrich lives through technology. Join us!
--- Day 18: Lavaduct Lagoon ---
Thanks to your efforts, the machine parts factory is one of the first
factories up and running since the lavafall came back. However, to catch
up with the large backlog of parts requests, the factory will also need a
large supply of lava for a while; the Elves have already started creating
a large lagoon nearby for this purpose.
However, they aren't sure the lagoon will be big enough; they've asked you
to take a look at the dig plan (your puzzle input). For example:
R 6 (#70c710)
D 5 (#0dc571)
L 2 (#5713f0)
D 2 (#d2c081)
R 2 (#59c680)
D 2 (#411b91)
L 5 (#8ceee2)
U 2 (#caa173)
L 1 (#1b58a2)
U 2 (#caa171)
R 2 (#7807d2)
U 3 (#a77fa3)
L 2 (#015232)
U 2 (#7a21e3)
The digger starts in a 1 meter cube hole in the ground. They then dig the
specified number of meters up (U), down (D), left (L), or right (R),
clearing full 1 meter cubes as they go. The directions are given as seen
from above, so if "up" were north, then "right" would be east, and so on.
Each trench is also listed with the color that the edge of the trench
should be painted as an [16]RGB hexadecimal color code.
When viewed from above, the above example dig plan would result in the
following loop of trench (#) having been dug out from otherwise
ground-level terrain (.):
#######
#.....#
###...#
..#...#
..#...#
###.###
#...#..
##..###
.#....#
.######
At this point, the trench could contain 38 cubic meters of lava. However,
this is just the edge of the lagoon; the next step is to dig out the
interior so that it is one meter deep as well:
#######
#######
#######
..#####
..#####
#######
#####..
#######
.######
.######
Now, the lagoon can contain a much more respectable 62 cubic meters of
lava. While the interior is dug out, the edges are also painted according
to the color codes in the dig plan.
The Elves are concerned the lagoon won't be large enough; if they follow
their dig plan, how many cubic meters of lava could it hold?
Your puzzle answer was 42317.
--- Part Two ---
The Elves were right to be concerned; the planned lagoon would be much too
small.
After a few minutes, someone realizes what happened; someone swapped the
color and instruction parameters when producing the dig plan. They don't
have time to fix the bug; one of them asks if you can extract the correct
instructions from the hexadecimal codes.
Each hexadecimal code is six hexadecimal digits long. The first five
hexadecimal digits encode the distance in meters as a five-digit
hexadecimal number. The last hexadecimal digit encodes the direction to
dig: 0 means R, 1 means D, 2 means L, and 3 means U.
So, in the above example, the hexadecimal codes can be converted into the
true instructions:
• #70c710 = R 461937
• #0dc571 = D 56407
• #5713f0 = R 356671
• #d2c081 = D 863240
• #59c680 = R 367720
• #411b91 = D 266681
• #8ceee2 = L 577262
• #caa173 = U 829975
• #1b58a2 = L 112010
• #caa171 = D 829975
• #7807d2 = L 491645
• #a77fa3 = U 686074
• #015232 = L 5411
• #7a21e3 = U 500254
Digging out this loop and its interior produces a lagoon that can hold an
impressive 952408144115 cubic meters of lava.
Convert the hexadecimal color codes into the correct instructions; if the
Elves follow this new dig plan, how many cubic meters of lava could the
lagoon hold?
Your puzzle answer was 83605563360288.
Both parts of this puzzle are complete! They provide two gold stars: **
At this point, you should [17]return to your Advent calendar and try
another puzzle.
If you still want to see it, you can [18]get your puzzle input.
You can also [Shareon [19]Twitter [20]Mastodon] this puzzle.
References
Visible links
1. https://adventofcode.com/
2. https://adventofcode.com/2023/about
3. https://adventofcode.com/2023/events
4. https://teespring.com/stores/advent-of-code
5. https://adventofcode.com/2023/settings
6. https://adventofcode.com/2023/auth/logout
7. Advent of Code Supporter
https://adventofcode.com/2023/support
8. https://adventofcode.com/2023
9. https://adventofcode.com/2023
10. https://adventofcode.com/2023/support
11. https://adventofcode.com/2023/sponsors
12. https://adventofcode.com/2023/leaderboard
13. https://adventofcode.com/2023/stats
14. https://adventofcode.com/2023/sponsors
15. https://jobs.bestbuy.com/bby?id=career_area&content=technology&career_site=Digital%20and%20Technology,Data%20and%20Analytics&spa=1&s=req_id_num
16. https://en.wikipedia.org/wiki/RGB_color_model#Numeric_representations
17. https://adventofcode.com/2023
18. https://adventofcode.com/2023/day/18/input
19. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Lavaduct+Lagoon%22+%2D+Day+18+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F18&related=ericwastl&hashtags=AdventOfCode
20. javascript:void(0);