Some work on AOC script. Needs more
This commit is contained in:
parent
c3ecf7a911
commit
b03a1a4c59
198
2023/day11/problem
Normal file
198
2023/day11/problem
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
[1]Advent of Code
|
||||||
|
|
||||||
|
• [2][About]
|
||||||
|
• [3][Events]
|
||||||
|
• [4][Shop]
|
||||||
|
• [5][Settings]
|
||||||
|
• [6][Log Out]
|
||||||
|
|
||||||
|
br0xen [7](AoC++) 36*
|
||||||
|
|
||||||
|
$year=[8]2023;
|
||||||
|
|
||||||
|
• [9][Calendar]
|
||||||
|
• [10][AoC++]
|
||||||
|
• [11][Sponsors]
|
||||||
|
• [12][Leaderboard]
|
||||||
|
• [13][Stats]
|
||||||
|
|
||||||
|
Our [14]sponsors help make Advent of Code possible:
|
||||||
|
[15]McGraw Hill - Transforming education, one line of code at a time.
|
||||||
|
|
||||||
|
--- Day 11: Cosmic Expansion ---
|
||||||
|
|
||||||
|
You continue following signs for "Hot Springs" and eventually come across
|
||||||
|
an [16]observatory. The Elf within turns out to be a researcher studying
|
||||||
|
cosmic expansion using the giant telescope here.
|
||||||
|
|
||||||
|
He doesn't know anything about the missing machine parts; he's only
|
||||||
|
visiting for this research project. However, he confirms that the hot
|
||||||
|
springs are the next-closest area likely to have people; he'll even take
|
||||||
|
you straight there once he's done with today's observation analysis.
|
||||||
|
|
||||||
|
Maybe you can help him with the analysis to speed things up?
|
||||||
|
|
||||||
|
The researcher has collected a bunch of data and compiled the data into a
|
||||||
|
single giant image (your puzzle input). The image includes empty space (.)
|
||||||
|
and galaxies (#). For example:
|
||||||
|
|
||||||
|
...#......
|
||||||
|
.......#..
|
||||||
|
#.........
|
||||||
|
..........
|
||||||
|
......#...
|
||||||
|
.#........
|
||||||
|
.........#
|
||||||
|
..........
|
||||||
|
.......#..
|
||||||
|
#...#.....
|
||||||
|
|
||||||
|
The researcher is trying to figure out the sum of the lengths of the
|
||||||
|
shortest path between every pair of galaxies. However, there's a catch:
|
||||||
|
the universe expanded in the time it took the light from those galaxies to
|
||||||
|
reach the observatory.
|
||||||
|
|
||||||
|
Due to something involving gravitational effects, only some space expands.
|
||||||
|
In fact, the result is that any rows or columns that contain no galaxies
|
||||||
|
should all actually be twice as big.
|
||||||
|
|
||||||
|
In the above example, three columns and two rows contain no galaxies:
|
||||||
|
|
||||||
|
v v v
|
||||||
|
...#......
|
||||||
|
.......#..
|
||||||
|
#.........
|
||||||
|
>..........<
|
||||||
|
......#...
|
||||||
|
.#........
|
||||||
|
.........#
|
||||||
|
>..........<
|
||||||
|
.......#..
|
||||||
|
#...#.....
|
||||||
|
^ ^ ^
|
||||||
|
|
||||||
|
These rows and columns need to be twice as big; the result of cosmic
|
||||||
|
expansion therefore looks like this:
|
||||||
|
|
||||||
|
....#........
|
||||||
|
.........#...
|
||||||
|
#............
|
||||||
|
.............
|
||||||
|
.............
|
||||||
|
........#....
|
||||||
|
.#...........
|
||||||
|
............#
|
||||||
|
.............
|
||||||
|
.............
|
||||||
|
.........#...
|
||||||
|
#....#.......
|
||||||
|
|
||||||
|
Equipped with this expanded universe, the shortest path between every pair
|
||||||
|
of galaxies can be found. It can help to assign every galaxy a unique
|
||||||
|
number:
|
||||||
|
|
||||||
|
....1........
|
||||||
|
.........2...
|
||||||
|
3............
|
||||||
|
.............
|
||||||
|
.............
|
||||||
|
........4....
|
||||||
|
.5...........
|
||||||
|
............6
|
||||||
|
.............
|
||||||
|
.............
|
||||||
|
.........7...
|
||||||
|
8....9.......
|
||||||
|
|
||||||
|
In these 9 galaxies, there are 36 pairs. Only count each pair once; order
|
||||||
|
within the pair doesn't matter. For each pair, find any shortest path
|
||||||
|
between the two galaxies using only steps that move up, down, left, or
|
||||||
|
right exactly one . or # at a time. (The shortest path between two
|
||||||
|
galaxies is allowed to pass through another galaxy.)
|
||||||
|
|
||||||
|
For example, here is one of the shortest paths between galaxies 5 and 9:
|
||||||
|
|
||||||
|
....1........
|
||||||
|
.........2...
|
||||||
|
3............
|
||||||
|
.............
|
||||||
|
.............
|
||||||
|
........4....
|
||||||
|
.5...........
|
||||||
|
.##.........6
|
||||||
|
..##.........
|
||||||
|
...##........
|
||||||
|
....##...7...
|
||||||
|
8....9.......
|
||||||
|
|
||||||
|
This path has length 9 because it takes a minimum of nine steps to get
|
||||||
|
from galaxy 5 to galaxy 9 (the eight locations marked # plus the step onto
|
||||||
|
galaxy 9 itself). Here are some other example shortest path lengths:
|
||||||
|
|
||||||
|
• Between galaxy 1 and galaxy 7: 15
|
||||||
|
• Between galaxy 3 and galaxy 6: 17
|
||||||
|
• Between galaxy 8 and galaxy 9: 5
|
||||||
|
|
||||||
|
In this example, after expanding the universe, the sum of the shortest
|
||||||
|
path between all 36 pairs of galaxies is 374.
|
||||||
|
|
||||||
|
Expand the universe, then find the length of the shortest path between
|
||||||
|
every pair of galaxies. What is the sum of these lengths?
|
||||||
|
|
||||||
|
Your puzzle answer was 9957702.
|
||||||
|
|
||||||
|
--- Part Two ---
|
||||||
|
|
||||||
|
The galaxies are much older (and thus much farther apart) than the
|
||||||
|
researcher initially estimated.
|
||||||
|
|
||||||
|
Now, instead of the expansion you did before, make each empty row or
|
||||||
|
column one million times larger. That is, each empty row should be
|
||||||
|
replaced with 1000000 empty rows, and each empty column should be replaced
|
||||||
|
with 1000000 empty columns.
|
||||||
|
|
||||||
|
(In the example above, if each empty row or column were merely 10 times
|
||||||
|
larger, the sum of the shortest paths between every pair of galaxies would
|
||||||
|
be 1030. If each empty row or column were merely 100 times larger, the sum
|
||||||
|
of the shortest paths between every pair of galaxies would be 8410.
|
||||||
|
However, your universe will need to expand far beyond these values.)
|
||||||
|
|
||||||
|
Starting with the same initial image, expand the universe according to
|
||||||
|
these new rules, then find the length of the shortest path between every
|
||||||
|
pair of galaxies. What is the sum of these lengths?
|
||||||
|
|
||||||
|
Your puzzle answer was 512240933238.
|
||||||
|
|
||||||
|
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://mheducation.com/
|
||||||
|
16. https://en.wikipedia.org/wiki/Observatory
|
||||||
|
17. https://adventofcode.com/2023
|
||||||
|
18. https://adventofcode.com/2023/day/11/input
|
||||||
|
19. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Cosmic+Expansion%22+%2D+Day+11+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F11&related=ericwastl&hashtags=AdventOfCode
|
||||||
|
20. javascript:void(0);
|
200
2023/day17/problem
Normal file
200
2023/day17/problem
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
[1]Advent of Code
|
||||||
|
|
||||||
|
• [2][About]
|
||||||
|
• [3][Events]
|
||||||
|
• [4][Shop]
|
||||||
|
• [5][Settings]
|
||||||
|
• [6][Log Out]
|
||||||
|
|
||||||
|
br0xen [7](AoC++) 36*
|
||||||
|
|
||||||
|
var y=[8]2023;
|
||||||
|
|
||||||
|
• [9][Calendar]
|
||||||
|
• [10][AoC++]
|
||||||
|
• [11][Sponsors]
|
||||||
|
• [12][Leaderboard]
|
||||||
|
• [13][Stats]
|
||||||
|
|
||||||
|
Our [14]sponsors help make Advent of Code possible:
|
||||||
|
[15]Bank of America - We use technology, models and data to make financial
|
||||||
|
lives better for our clients and communities.
|
||||||
|
|
||||||
|
--- Day 17: Clumsy Crucible ---
|
||||||
|
|
||||||
|
The lava starts flowing rapidly once the Lava Production Facility is
|
||||||
|
operational. As you leave, the reindeer offers you a parachute, allowing
|
||||||
|
you to quickly reach Gear Island.
|
||||||
|
|
||||||
|
As you descend, your bird's-eye view of Gear Island reveals why you had
|
||||||
|
trouble finding anyone on your way up: half of Gear Island is empty, but
|
||||||
|
the half below you is a giant factory city!
|
||||||
|
|
||||||
|
You land near the gradually-filling pool of lava at the base of your new
|
||||||
|
lavafall. Lavaducts will eventually carry the lava throughout the city,
|
||||||
|
but to make use of it immediately, Elves are loading it into large
|
||||||
|
[16]crucibles on wheels.
|
||||||
|
|
||||||
|
The crucibles are top-heavy and pushed by hand. Unfortunately, the
|
||||||
|
crucibles become very difficult to steer at high speeds, and so it can be
|
||||||
|
hard to go in a straight line for very long.
|
||||||
|
|
||||||
|
To get Desert Island the machine parts it needs as soon as possible,
|
||||||
|
you'll need to find the best way to get the crucible from the lava pool to
|
||||||
|
the machine parts factory. To do this, you need to minimize heat loss
|
||||||
|
while choosing a route that doesn't require the crucible to go in a
|
||||||
|
straight line for too long.
|
||||||
|
|
||||||
|
Fortunately, the Elves here have a map (your puzzle input) that uses
|
||||||
|
traffic patterns, ambient temperature, and hundreds of other parameters to
|
||||||
|
calculate exactly how much heat loss can be expected for a crucible
|
||||||
|
entering any particular city block.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
2413432311323
|
||||||
|
3215453535623
|
||||||
|
3255245654254
|
||||||
|
3446585845452
|
||||||
|
4546657867536
|
||||||
|
1438598798454
|
||||||
|
4457876987766
|
||||||
|
3637877979653
|
||||||
|
4654967986887
|
||||||
|
4564679986453
|
||||||
|
1224686865563
|
||||||
|
2546548887735
|
||||||
|
4322674655533
|
||||||
|
|
||||||
|
Each city block is marked by a single digit that represents the amount of
|
||||||
|
heat loss if the crucible enters that block. The starting point, the lava
|
||||||
|
pool, is the top-left city block; the destination, the machine parts
|
||||||
|
factory, is the bottom-right city block. (Because you already start in the
|
||||||
|
top-left block, you don't incur that block's heat loss unless you leave
|
||||||
|
that block and then return to it.)
|
||||||
|
|
||||||
|
Because it is difficult to keep the top-heavy crucible going in a straight
|
||||||
|
line for very long, it can move at most three blocks in a single direction
|
||||||
|
before it must turn 90 degrees left or right. The crucible also can't
|
||||||
|
reverse direction; after entering each city block, it may only turn left,
|
||||||
|
continue straight, or turn right.
|
||||||
|
|
||||||
|
One way to minimize heat loss is this path:
|
||||||
|
|
||||||
|
2>>34^>>>1323
|
||||||
|
32v>>>35v5623
|
||||||
|
32552456v>>54
|
||||||
|
3446585845v52
|
||||||
|
4546657867v>6
|
||||||
|
14385987984v4
|
||||||
|
44578769877v6
|
||||||
|
36378779796v>
|
||||||
|
465496798688v
|
||||||
|
456467998645v
|
||||||
|
12246868655<v
|
||||||
|
25465488877v5
|
||||||
|
43226746555v>
|
||||||
|
|
||||||
|
This path never moves more than three consecutive blocks in the same
|
||||||
|
direction and incurs a heat loss of only 102.
|
||||||
|
|
||||||
|
Directing the crucible from the lava pool to the machine parts factory,
|
||||||
|
but not moving more than three consecutive blocks in the same direction,
|
||||||
|
what is the least heat loss it can incur?
|
||||||
|
|
||||||
|
Your puzzle answer was 1001.
|
||||||
|
|
||||||
|
--- Part Two ---
|
||||||
|
|
||||||
|
The crucibles of lava simply aren't large enough to provide an adequate
|
||||||
|
supply of lava to the machine parts factory. Instead, the Elves are going
|
||||||
|
to upgrade to ultra crucibles.
|
||||||
|
|
||||||
|
Ultra crucibles are even more difficult to steer than normal crucibles.
|
||||||
|
Not only do they have trouble going in a straight line, but they also have
|
||||||
|
trouble turning!
|
||||||
|
|
||||||
|
Once an ultra crucible starts moving in a direction, it needs to move a
|
||||||
|
minimum of four blocks in that direction before it can turn (or even
|
||||||
|
before it can stop at the end). However, it will eventually start to get
|
||||||
|
wobbly: an ultra crucible can move a maximum of ten consecutive blocks
|
||||||
|
without turning.
|
||||||
|
|
||||||
|
In the above example, an ultra crucible could follow this path to minimize
|
||||||
|
heat loss:
|
||||||
|
|
||||||
|
2>>>>>>>>1323
|
||||||
|
32154535v5623
|
||||||
|
32552456v4254
|
||||||
|
34465858v5452
|
||||||
|
45466578v>>>>
|
||||||
|
143859879845v
|
||||||
|
445787698776v
|
||||||
|
363787797965v
|
||||||
|
465496798688v
|
||||||
|
456467998645v
|
||||||
|
122468686556v
|
||||||
|
254654888773v
|
||||||
|
432267465553v
|
||||||
|
|
||||||
|
In the above example, an ultra crucible would incur the minimum possible
|
||||||
|
heat loss of 94.
|
||||||
|
|
||||||
|
Here's another example:
|
||||||
|
|
||||||
|
111111111111
|
||||||
|
999999999991
|
||||||
|
999999999991
|
||||||
|
999999999991
|
||||||
|
999999999991
|
||||||
|
|
||||||
|
Sadly, an ultra crucible would need to take an unfortunate path like this
|
||||||
|
one:
|
||||||
|
|
||||||
|
1>>>>>>>1111
|
||||||
|
9999999v9991
|
||||||
|
9999999v9991
|
||||||
|
9999999v9991
|
||||||
|
9999999v>>>>
|
||||||
|
|
||||||
|
This route causes the ultra crucible to incur the minimum possible heat
|
||||||
|
loss of 71.
|
||||||
|
|
||||||
|
Directing the ultra crucible from the lava pool to the machine parts
|
||||||
|
factory, what is the least heat loss it can incur?
|
||||||
|
|
||||||
|
Your puzzle answer was 1197.
|
||||||
|
|
||||||
|
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://careers.bankofamerica.com/
|
||||||
|
16. https://en.wikipedia.org/wiki/Crucible
|
||||||
|
17. https://adventofcode.com/2023
|
||||||
|
18. https://adventofcode.com/2023/day/17/input
|
||||||
|
19. https://twitter.com/intent/tweet?text=I%27ve+completed+%22Clumsy+Crucible%22+%2D+Day+17+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode
|
||||||
|
20. javascript:void(0);
|
11
sbin/aoc
11
sbin/aoc
@ -35,11 +35,12 @@ getproblem() {
|
|||||||
DY=${PWD:5:5}
|
DY=${PWD:5:5}
|
||||||
DY=${DY/day0/}
|
DY=${DY/day0/}
|
||||||
DY=${DY/day/}
|
DY=${DY/day/}
|
||||||
|
DIRDY=$DY
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "$AOCROOT/$YR/day$DIRDY" ]]; then
|
if [[ ! -d "$AOCROOT/$YR/day$DY" ]]; then
|
||||||
mkdir "$AOCROOT/$YR/day$DIRDY"
|
mkdir "$AOCROOT/$YR/day$DY"
|
||||||
fi
|
fi
|
||||||
cd "$AOCROOT/$YR/day$DIRDY"
|
cd "$AOCROOT/$YR/day$DY"
|
||||||
if [[ -f "problem" ]]; then
|
if [[ -f "problem" ]]; then
|
||||||
echo "Found problem file."
|
echo "Found problem file."
|
||||||
if [[ $1 != "-f" ]]; then
|
if [[ $1 != "-f" ]]; then
|
||||||
@ -50,8 +51,8 @@ getproblem() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove any zero padding from day
|
# Remove any zero padding from day
|
||||||
DY=$(echo "$CURRDAY"|awk '$0*=1')
|
DY=$(echo "$DY"|awk '$0*=1')
|
||||||
echo "Getting problem at $CURRYEAR/day/$DY"
|
echo "Getting problem at $YR/day/$DY"
|
||||||
elinks -dump https://adventofcode.com/$CURRYEAR/day/$DY > problem
|
elinks -dump https://adventofcode.com/$CURRYEAR/day/$DY > problem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user