Compare commits

...

2 Commits

Author SHA1 Message Date
hedy c1ef8d9616
Restructure and add README.md to all solved puzzles
Using the fresh new bin/new script of course!
2022-12-23 21:06:53 +08:00
hedy cc6d60d02f
Full blown AoC new puzzles setup script let's go!
I already wrote so much docs

I'm literally too tired to write a 1000-word commit message

Please see bin/new

Tested it a bit, I guess

Well, it works.

Could be better, of course, lol

Good luck \o/

pfffffft I should do some *actual* AoC stuff now
2022-12-23 20:53:09 +08:00
34 changed files with 3044 additions and 193 deletions

3
.editdesc.vim Normal file
View File

@ -0,0 +1,3 @@
%g/answer was/d
g/this puzzle are complete!/normal dGdd
%s/\n\n```\n\n/\r```\r\r/g

3
.envrc
View File

@ -1,3 +1,4 @@
source ../.envrc
source_up # source parent directory's .envrc
# set $AOCROOT to the root directory of the AoC repo in the .envrc of the parent directory.
export AOC_SKELPATH=$AOCROOT/skel
export PATH=$PATH:$AOCROOT/bin

View File

@ -1,14 +1,13 @@
# Day 1
\--- Day 1: Calorie Counting ---
----------
## Part One
Santa's reindeer typically eat regular reindeer food, but they need a lot of [magical energy](/2018/day/25) to deliver presents on Christmas. For that, their favorite snack is a special type of *star* fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.
Santa's reindeer typically eat regular reindeer food, but they need a lot of magical energy to deliver presents on Christmas. For that, their favorite snack is a special type of star fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.
To supply enough magical energy, the expedition needs to retrieve a minimum of *fifty stars* by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case.
To supply enough magical energy, the expedition needs to retrieve a minimum of fifty stars by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case.
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!
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 jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of Calories each Elf is carrying (your puzzle input).
The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of *Calories* each Elf is carrying (your puzzle input).
The Elves take turns writing down the number of Calories contained by the various meals, snacks, rations, etc. that they've brought with them, one item per line. Each Elf separates their own inventory from the previous Elf's inventory (if any) by a blank line.
@ -33,22 +32,25 @@ For example, suppose the Elves finish writing their items' Calories and end up w
This list represents the Calories of the food carried by five Elves:
- The first Elf is carrying food with 1000, 2000, and 3000 Calories, a total of 6000 Calories.
- The second Elf is carrying one food item with 4000 Calories.
- The third Elf is carrying food with 5000 and 6000 Calories, a total of 11000 Calories.
- The fourth Elf is carrying food with 7000, 8000, and 9000 Calories, a total of 24000 Calories.
- The fifth Elf is carrying one food item with 10000 Calories.
* The first Elf is carrying food with `1000`, `2000`, and `3000` Calories, a total of `*6000*` Calories.
* The second Elf is carrying one food item with `*4000*` Calories.
* The third Elf is carrying food with `5000` and `6000` Calories, a total of `*11000*` Calories.
* The fourth Elf is carrying food with `7000`, `8000`, and `9000` Calories, a total of `*24000*` Calories.
* The fifth Elf is carrying one food item with `*10000*` Calories.
In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the most Calories. In the example above, this is 24000 (carried by the fourth Elf).
In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the *most* Calories. In the example above, this is *`24000`* (carried by the fourth Elf).
Find the Elf carrying the most Calories. How many total Calories is that Elf carrying?
Find the Elf carrying the most Calories. *How many total Calories is that Elf carrying?*
## Part Two
By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most Calories of food might eventually run out of snacks.
\--- Part Two ---
----------
To avoid this unacceptable situation, the Elves would instead like to know the total Calories carried by the top three Elves carrying the most Calories. That way, even if one of those Elves runs out of snacks, they still have two backups.
By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most Calories of food might eventually *run out of snacks*.
In the example above, the top three Elves are the fourth Elf (with 24000 Calories), then the third Elf (with 11000 Calories), then the fifth Elf (with 10000 Calories). The sum of the Calories carried by these three elves is 45000.
To avoid this unacceptable situation, the Elves would instead like to know the total Calories carried by the *top three* Elves carrying the most Calories. That way, even if one of those Elves runs out of snacks, they still have two backups.
In the example above, the top three Elves are the fourth Elf (with `24000` Calories), then the third Elf (with `11000` Calories), then the fifth Elf (with `10000` Calories). The sum of the Calories carried by these three elves is `*45000*`.
Find the top three Elves carrying the most Calories. *How many Calories are those Elves carrying in total?*
Find the top three Elves carrying the most Calories. How many Calories are those Elves carrying in total?

View File

@ -1,54 +0,0 @@
# Day 1: Calorie Counting
Santa's reindeer typically eat regular reindeer food, but they need a lot of [magical energy](/2018/day/25) to deliver presents on Christmas. For that, their favorite snack is a special type of *star* fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.
To supply enough magical energy, the expedition needs to retrieve a minimum of *fifty stars* by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case.
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 jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of *Calories* each Elf is carrying (your puzzle input).
The Elves take turns writing down the number of Calories contained by the various meals, snacks, rations, etc. that they've brought with them, one item per line. Each Elf separates their own inventory from the previous Elf's inventory (if any) by a blank line.
For example, suppose the Elves finish writing their items' Calories and end up with the following list:
```
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000
```
This list represents the Calories of the food carried by five Elves:
* The first Elf is carrying food with `1000`, `2000`, and `3000` Calories, a total of `*6000*` Calories.
* The second Elf is carrying one food item with `*4000*` Calories.
* The third Elf is carrying food with `5000` and `6000` Calories, a total of `*11000*` Calories.
* The fourth Elf is carrying food with `7000`, `8000`, and `9000` Calories, a total of `*24000*` Calories.
* The fifth Elf is carrying one food item with `*10000*` Calories.
In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the *most* Calories. In the example above, this is *`24000`* (carried by the fourth Elf).
Find the Elf carrying the most Calories. *How many total Calories is that Elf carrying?*
# Part Two
By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most Calories of food might eventually *run out of snacks*.
To avoid this unacceptable situation, the Elves would instead like to know the total Calories carried by the *top three* Elves carrying the most Calories. That way, even if one of those Elves runs out of snacks, they still have two backups.
In the example above, the top three Elves are the fourth Elf (with `24000` Calories), then the third Elf (with `11000` Calories), then the fifth Elf (with `10000` Calories). The sum of the Calories carried by these three elves is `*45000*`.
Find the top three Elves carrying the most Calories. *How many Calories are those Elves carrying in total?*

View File

@ -1,4 +1,5 @@
# Day 2: Rock Paper Scissors
\--- Day 2: Rock Paper Scissors ---
----------
The Elves begin to set up camp on the beach. To decide whose tent gets to be closest to the snack storage, a giant [Rock Paper Scissors](https://en.wikipedia.org/wiki/Rock_paper_scissors) tournament is already in progress.
@ -31,7 +32,8 @@ In this example, if you were to follow the strategy guide, you would get a total
*What would your total score be if everything goes exactly according to your strategy guide?*
# Part Two
\--- Part Two ---
----------
The Elf finishes helping with the tent and sneaks back over to you. "Anyway, the second column says how the round needs to end: `X` means you need to lose, `Y` means you need to end the round in a draw, and `Z` means you need to win. Good luck!"

View File

@ -18,7 +18,6 @@ PmmdzqPrVvPwwTWBwg
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw
```
* The first rucksack contains the items `vJrwpWtwJgWrhcsFMMfFFhFp`, which means its first compartment contains the items `vJrwpWtwJgWr`, while the second compartment contains the items `hcsFMMfFFhFp`. The only item type that appears in both compartments is lowercase `*p*`.
@ -37,7 +36,6 @@ In the above example, the priority of the item type that appears in both compart
Find the item type that appears in both compartments of each rucksack. *What is the sum of the priorities of those item types?*
Your puzzle answer was `8109`.
\--- Part Two ---
----------
@ -56,7 +54,6 @@ Every set of three lines in your list corresponds to a single group, but each gr
vJrwpWtwJgWrhcsFMMfFFhFp
jqHRNqRjqzjGDLGLrsFMfFZSrLrFZsSL
PmmdzqPrVvPwwTWBwg
```
And the second group's rucksacks are the next three lines:
@ -65,7 +62,6 @@ And the second group's rucksacks are the next three lines:
wMqvLMZHhHMvwLHjbvcjnnSBnvTQFn
ttgJtRGJQctTZtZT
CrZsJsPPZsGzwwsLwLmpwMDw
```
In the first group, the only item type that appears in all three rucksacks is lowercase `r`; this must be their badges. In the second group, their badge item type must be `Z`.
@ -74,12 +70,3 @@ Priorities for these items must still be found to organize the sticker attachmen
Find the item type that corresponds to the badges of each three-Elf group. *What is the sum of the priorities of those item types?*
Your puzzle answer was `2738`.
Both parts of this puzzle are complete! They provide two gold stars: \*\*
At this point, you should [return to your Advent calendar](/2022) and try another puzzle.
If you still want to see it, you can [get your puzzle input](3/input).
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=I%27ve+completed+%22Rucksack+Reorganization%22+%2D+Day+3+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F3&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

View File

@ -14,7 +14,6 @@ For example, consider the following list of section assignment pairs:
2-8,3-7
6-6,4-6
2-6,4-8
```
For the first few pairs, this list means:
@ -43,15 +42,26 @@ This example list uses single-digit section IDs to make it easier to draw; your
.23456... 2-6
...45678. 4-8
```
Some of the pairs have noticed that one of their assignments *fully contains* the other. For example, `2-8` fully contains `3-7`, and `6-6` is fully contained by `4-6`. In pairs where one assignment fully contains the other, one Elf in the pair would be exclusively cleaning sections their partner will already be cleaning, so these seem like the most in need of reconsideration. In this example, there are `*2*` such pairs.
*In how many assignment pairs does one range fully contain the other?*
To begin, [get your puzzle input](4/input).
Answer:
\--- Part Two ---
----------
It seems like there is still quite a bit of duplicate work planned. Instead, the Elves would like to know the number of pairs that *overlap at all*.
In the above example, the first two pairs (`2-4,6-8` and `2-3,4-5`) don't overlap, while the remaining four pairs (`5-7,7-9`, `2-8,3-7`, `6-6,4-6`, and `2-6,4-8`) do overlap:
* `5-7,7-9` overlaps in a single section, `7`.
* `2-8,3-7` overlaps all of the sections `3` through `7`.
* `6-6,4-6` overlaps in a single section, `6`.
* `2-6,4-8` overlaps in sections `4`, `5`, and `6`.
So, in this example, the number of overlapping assignment pairs is `*4*`.
*In how many assignment pairs do the ranges overlap?*
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Camp+Cleanup%22+%2D+Day+4+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F4&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

View File

@ -1,4 +1,5 @@
# Day 5: Supply Stacks
\--- Day 5: Supply Stacks ---
----------
The expedition can depart as soon as the final supplies have been unloaded from the ships. Supplies are stored in stacks of marked *crates*, but because the needed supplies are buried under many other crates, the crates need to be rearranged.
@ -18,7 +19,6 @@ move 1 from 2 to 1
move 3 from 1 to 3
move 2 from 2 to 1
move 1 from 1 to 2
```
In this example, there are three stacks of crates. Stack 1 contains two crates: crate `Z` is on the bottom, and crate `N` is on top. Stack 2 contains three crates; from bottom to top, they are crates `M`, `C`, and `D`. Finally, stack 3 contains a single crate, `P`.
@ -30,7 +30,6 @@ Then, the rearrangement procedure is given. In each step of the procedure, a qua
[N] [C]
[Z] [M] [P]
1 2 3
```
In the second step, three crates are moved from stack 1 to stack 3. Crates are moved *one at a time*, so the first crate to be moved (`D`) ends up below the second and third crates:
@ -41,7 +40,6 @@ In the second step, three crates are moved from stack 1 to stack 3. Crates are m
[C] [D]
[M] [P]
1 2 3
```
Then, both crates are moved from stack 2 to stack 1. Again, because crates are moved *one at a time*, crate `C` ends up below crate `M`:
@ -52,7 +50,6 @@ Then, both crates are moved from stack 2 to stack 1. Again, because crates are m
[M] [D]
[C] [P]
1 2 3
```
Finally, one crate is moved from stack 1 to stack 2:
@ -63,7 +60,6 @@ Finally, one crate is moved from stack 1 to stack 2:
[D]
[C] [M] [P]
1 2 3
```
The Elves just need to know *which crate will end up on top of each stack*; in this example, the top crates are `C` in stack 1, `M` in stack 2, and `Z` in stack 3, so you should combine these together and give the Elves the message `*CMZ*`.
@ -71,7 +67,8 @@ The Elves just need to know *which crate will end up on top of each stack*; in t
*After the rearrangement procedure completes, what crate ends up on top of each stack?*
# Part Two
\--- Part Two ---
----------
As you watch the crane operator expertly rearrange the crates, you notice the process isn't following your prediction.
@ -86,7 +83,6 @@ Again considering the example above, the crates begin in the same configuration:
[N] [C]
[Z] [M] [P]
1 2 3
```
Moving a single crate from stack 2 to stack 1 behaves the same as before:
@ -96,7 +92,6 @@ Moving a single crate from stack 2 to stack 1 behaves the same as before:
[N] [C]
[Z] [M] [P]
1 2 3
```
However, the action of moving three crates from stack 1 to stack 3 means that those three moved crates *stay in the same order*, resulting in this new configuration:
@ -107,7 +102,6 @@ However, the action of moving three crates from stack 1 to stack 3 means that th
[C] [Z]
[M] [P]
1 2 3
```
Next, as both crates are moved from stack 2 to stack 1, they *retain their order* as well:
@ -118,7 +112,6 @@ Next, as both crates are moved from stack 2 to stack 1, they *retain their order
[C] [Z]
[M] [P]
1 2 3
```
Finally, a single crate is still moved from stack 1 to stack 2, but now it's crate `C` that gets moved:
@ -129,7 +122,6 @@ Finally, a single crate is still moved from stack 1 to stack 2, but now it's cra
[Z]
[M] [C] [P]
1 2 3
```
In this example, the CrateMover 9001 has put the crates in a totally different order: `*MCD*`.

54
2022/06/README.md Normal file
View File

@ -0,0 +1,54 @@
\--- Day 6: Tuning Trouble ---
----------
The preparations are finally complete; you and the Elves leave camp on foot and begin to make your way toward the *star* fruit grove.
As you move through the dense undergrowth, one of the Elves gives you a handheld *device*. He says that it has many fancy features, but the most important one to set up right now is the *communication system*.
However, because he's heard you have [significant](/2016/day/6) [experience](/2016/day/25) [dealing](/2019/day/7) [with](/2019/day/9) [signal-based](/2019/day/16) [systems](/2021/day/25), he convinced the other Elves that it would be okay to give you their one malfunctioning device - surely you'll have no problem fixing it.
As if inspired by comedic timing, the device emits a few colorful sparks.
To be able to communicate with the Elves, the device needs to *lock on to their signal*. The signal is a series of seemingly-random characters that the device receives one at a time.
To fix the communication system, you need to add a subroutine to the device that detects a *start-of-packet marker* in the datastream. In the protocol being used by the Elves, the start of a packet is indicated by a sequence of *four characters that are all different*.
The device will send your subroutine a datastream buffer (your puzzle input); your subroutine needs to identify the first position where the four most recently received characters were all different. Specifically, it needs to report the number of characters from the beginning of the buffer to the end of the first such four-character marker.
For example, suppose you receive the following datastream buffer:
```
mjqjpqmgbljsphdztnvjfqwrcgsmlb
```
After the first three characters (`mjq`) have been received, there haven't been enough characters received yet to find the marker. The first time a marker could occur is after the fourth character is received, making the most recent four characters `mjqj`. Because `j` is repeated, this isn't a marker.
The first time a marker appears is after the *seventh* character arrives. Once it does, the last four characters received are `jpqm`, which are all different. In this case, your subroutine should report the value `*7*`, because the first start-of-packet marker is complete after 7 characters have been processed.
Here are a few more examples:
* `bvwbjplbgvbhsrlpgdmjqwftvncz`: first marker after character `*5*`
* `nppdvjthqldpwncqszvftbrmjlhg`: first marker after character `*6*`
* `nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg`: first marker after character `*10*`
* `zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw`: first marker after character `*11*`
*How many characters need to be processed before the first start-of-packet marker is detected?*
\--- Part Two ---
----------
Your device's communication system is correctly detecting packets, but still isn't working. It looks like it also needs to look for *messages*.
A *start-of-message marker* is just like a start-of-packet marker, except it consists of *14 distinct characters* rather than 4.
Here are the first positions of start-of-message markers for all of the above examples:
* `mjqjpqmgbljsphdztnvjfqwrcgsmlb`: first marker after character `*19*`
* `bvwbjplbgvbhsrlpgdmjqwftvncz`: first marker after character `*23*`
* `nppdvjthqldpwncqszvftbrmjlhg`: first marker after character `*23*`
* `nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg`: first marker after character `*29*`
* `zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw`: first marker after character `*26*`
*How many characters need to be processed before the first start-of-message marker is detected?*

View File

@ -1,4 +1,5 @@
# Day 7: No Space Left On Device
\--- Day 7: No Space Left On Device ---
----------
You can hear birds chirping and raindrops hitting leaves as the expedition proceeds. Occasionally, you can even hear much louder sounds in the distance; how big do the animals get out here, anyway?
@ -7,7 +8,6 @@ The device the Elves gave you has problems with more than just its communication
```
$ system-update --please --pretty-please-with-sugar-on-top
Error: No space left on device
```
Perhaps you can delete some files to make space for the update?
@ -38,7 +38,6 @@ $ ls
8033020 d.log
5626152 d.ext
7214296 k
```
The filesystem consists of a tree of files (plain data) and directories (which can contain other directories or files). The outermost directory is called `/`. You can navigate around the filesystem, moving into or out of directories and listing the contents of the directory you're currently in.
@ -71,7 +70,6 @@ Given the commands and output in the example above, you can determine that the f
- d.log (file, size=8033020)
- d.ext (file, size=5626152)
- k (file, size=7214296)
```
Here, there are four directories: `/` (the outermost directory), `a` and `d` (which are in `/`), and `e` (which is in `a`). These directories also contain files of various sizes.
@ -90,7 +88,8 @@ To begin, find all of the directories with a total size of *at most 100000*, the
Find all of the directories with a total size of at most 100000. *What is the sum of the total sizes of those directories?*
# Part Two
\--- Part Two ---
----------
Now, you're ready to choose a directory to delete.
@ -108,3 +107,4 @@ To achieve this, you have the following options:
Directories `e` and `a` are both too small; deleting them would not free up enough space. However, directories `d` and `/` are both big enough! Between these, choose the *smallest*: `d`, increasing unused space by `*24933642*`.
Find the smallest directory that, if deleted, would free up enough space on the filesystem to run the update. *What is the total size of that directory?*

View File

@ -1,4 +1,5 @@
# Day 8: Treetop Tree House
\--- Day 8: Treetop Tree House ---
----------
The expedition comes across a peculiar patch of tall trees all planted carefully in a grid. The Elves explain that a previous expedition planted these trees as a reforestation effort. Now, they're curious if this would be a good location for a [tree house](https://en.wikipedia.org/wiki/Tree_house).
@ -12,7 +13,6 @@ The Elves have already launched a [quadcopter](https://en.wikipedia.org/wiki/Qua
65332
33549
35390
```
Each tree is represented as a single digit whose value is its height, where `0` is the shortest and `9` is the tallest.
@ -34,7 +34,8 @@ With 16 trees visible on the edge and another 5 visible in the interior, a total
Consider your map; *how many trees are visible from outside the grid?*
# Part Two
\--- Part Two ---
----------
Content with the amount of tree cover available, the Elves just need to know the best spot to build their tree house: they would like to be able to see a lot of *trees*.
@ -50,7 +51,6 @@ In the example above, consider the middle `5` in the second row:
65332
33549
35390
```
* Looking up, its view is not blocked; it can see `*1*` tree (of height `3`).
@ -68,7 +68,6 @@ However, you can do even better: consider the tree of height `5` in the middle o
65332
33549
35390
```
* Looking up, its view is blocked at `*2*` trees (by another tree with a height of `5`).
@ -79,3 +78,4 @@ However, you can do even better: consider the tree of height `5` in the middle o
This tree's scenic score is `*8*` (`2 * 2 * 1 * 2`); this is the ideal spot for the tree house.
Consider each tree on your map. *What is the highest scenic score possible for any tree?*

View File

@ -1,4 +1,5 @@
# Day 9: Rope Bridge
\--- Day 9: Rope Bridge ---
----------
This rope bridge creaks as you walk along it. You aren't sure how old it is, or whether it can even support your weight.
@ -25,7 +26,6 @@ Due to the aforementioned Planck lengths, the rope must be quite short; in fact,
...
.H. (H covers T)
...
```
If the head is ever two steps directly up, down, left, or right from the tail, the tail must also move one step in that direction so it remains close enough:
@ -40,7 +40,6 @@ If the head is ever two steps directly up, down, left, or right from the tail, t
.H. -> ... -> .T.
... .H. .H.
... ... ...
```
Otherwise, if the head and tail aren't touching and aren't in the same row or column, the tail always moves one step diagonally to keep up:
@ -57,7 +56,6 @@ Otherwise, if the head and tail aren't touching and aren't in the same row or co
..H.. -> ...H. -> ..TH.
.T... .T... .....
..... ..... .....
```
You just need to work out where the tail goes as the head follows a series of motions. Assume the head and the tail both start at the same position, overlapping.
@ -73,7 +71,6 @@ R 4
D 1
L 5
R 2
```
This series of motions moves the head *right* four steps, then *up* four steps, then *left* three steps, then *down* one step, and so on. After each step, you'll need to update the position of the tail if the step means the head is no longer adjacent to the tail. Visually, these motions occur as follows (`s` marks the starting position as a reference point):
@ -246,7 +243,6 @@ s.....
.TH...
......
s.....
```
After simulating the rope, you can count up all of the positions the *tail visited at least once*. In this diagram, `s` again marks the starting position (which the tail also visited) and `#` marks other positions the tail visited:
@ -257,7 +253,6 @@ After simulating the rope, you can count up all of the positions the *tail visit
.####.
....#.
s###..
```
So, there are `*13*` positions the tail visited at least once.
@ -265,7 +260,8 @@ So, there are `*13*` positions the tail visited at least once.
Simulate your complete hypothetical series of motions. *How many positions does the tail of the rope visit at least once?*
# Part Two
\--- Part Two ---
----------
A rope snaps! Suddenly, the river is getting a lot closer than you remember. The bridge is still there, but some of the ropes that broke are now whipping toward you as you fall through the air!
@ -443,7 +439,6 @@ H123.. (2 covers 4)
.1H3.. (H covers 2, 4)
.5....
6..... (6 covers 7, 8, 9, s)
```
Now, you need to keep track of the positions the new tail, `9`, visits. In this example, the tail never moves, and so it only visits `*1*` position. However, *be careful*: more types of motion are possible than before, so you might want to visually compare your simulated rope to the one above.
@ -459,7 +454,6 @@ R 17
D 10
L 25
U 20
```
These motions occur as follows (individual steps are not shown):
@ -680,7 +674,6 @@ H.........................
..........................
..........................
..........................
```
Now, the tail (`9`) visits `*36*` positions (including `s`) at least once:
@ -707,7 +700,7 @@ Now, the tail (`9`) visits `*36*` positions (including `s`) at least once:
.......#..........#.......
........#........#........
.........########.........
```
Simulate your complete series of motions on a larger rope with ten knots. *How many positions does the tail of the rope visit at least once?*

View File

@ -1,4 +1,5 @@
# Day 10: Cathode-Ray Tube
\--- Day 10: Cathode-Ray Tube ---
----------
You avoid the ropes, plunge into the river, and swim to shore.
@ -21,7 +22,6 @@ Consider the following small program:
noop
addx 3
addx -5
```
Execution of this program proceeds as follows:
@ -183,7 +183,6 @@ addx -11
noop
noop
noop
```
The interesting signal strengths can be determined as follows:
@ -200,7 +199,8 @@ The sum of these signal strengths is `*13140*`.
Find the signal strength during the 20th, 60th, 100th, 140th, 180th, and 220th cycles. *What is the sum of these six signal strengths?*
# Part Two
\--- Part Two ---
----------
It seems like the `X` register controls the horizontal position of a [sprite](https://en.wikipedia.org/wiki/Sprite_(computer_graphics)). Specifically, the sprite is 3 pixels wide, and the `X` register sets the horizontal position of the *middle* of that sprite. (In this system, there is no such thing as "vertical position": if the sprite's horizontal position puts its pixels where the CRT is currently drawing, then those pixels will be drawn.)
@ -215,7 +215,6 @@ Cycle 81 -> ######################################## <- Cycle 120
Cycle 121 -> ######################################## <- Cycle 160
Cycle 161 -> ######################################## <- Cycle 200
Cycle 201 -> ######################################## <- Cycle 240
```
So, by [carefully](https://en.wikipedia.org/wiki/Racing_the_Beam) [timing](https://www.youtube.com/watch?v=sJFnWZH5FXc) the CPU instructions and the CRT drawing operations, you should be able to determine whether the sprite is visible the instant each pixel is drawn. If the sprite is positioned such that one of its three pixels is the pixel currently being drawn, the screen produces a *lit* pixel (`#`); otherwise, the screen leaves the pixel *dark* (`.`).
@ -319,7 +318,6 @@ During cycle 21: CRT draws pixel in position 20
Current CRT row: ##..##..##..##..##..#
End of cycle 21: finish executing addx -1 (Register X is now 20)
Sprite position: ...................###..................
```
Allowing the program to run to completion causes the CRT to produce the following image:
@ -331,7 +329,7 @@ Allowing the program to run to completion causes the CRT to produce the followin
#####.....#####.....#####.....#####.....
######......######......######......####
#######.......#######.......#######.....
```
Render the image given by your program. *What eight capital letters appear on your CRT?*

69
2022/12/README.md Normal file
View File

@ -0,0 +1,69 @@
\--- Day 12: Hill Climbing Algorithm ---
----------
You try contacting the Elves using your handheld device, but the river you're following must be too low to get a decent signal.
You ask the device for a heightmap of the surrounding area (your puzzle input). The heightmap shows the local area from above broken into a grid; the elevation of each square of the grid is given by a single lowercase letter, where `a` is the lowest elevation, `b` is the next-lowest, and so on up to the highest elevation, `z`.
Also included on the heightmap are marks for your current position (`S`) and the location that should get the best signal (`E`). Your current position (`S`) has elevation `a`, and the location that should get the best signal (`E`) has elevation `z`.
You'd like to reach `E`, but to save energy, you should do it in *as few steps as possible*. During each step, you can move exactly one square up, down, left, or right. To avoid needing to get out your climbing gear, the elevation of the destination square can be *at most one higher* than the elevation of your current square; that is, if your current elevation is `m`, you could step to elevation `n`, but not to elevation `o`. (This also means that the elevation of the destination square can be much lower than the elevation of your current square.)
For example:
```
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
```
Here, you start in the top-left corner; your goal is near the middle. You could start by moving down or right, but eventually you'll need to head toward the `e` at the bottom. From there, you can spiral around to the goal:
```
v..v<<<<
>v.vv<<^
.>vv>E^^
..v>>>^^
..>>>>>^
```
In the above diagram, the symbols indicate whether the path exits each square moving up (`^`), down (`v`), left (`<`), or right (`>`). The location that should get the best signal is still `E`, and `.` marks unvisited squares.
This path reaches the goal in `*31*` steps, the fewest possible.
*What is the fewest steps required to move from your current position to the location that should get the best signal?*
\--- Part Two ---
----------
As you walk up the hill, you suspect that the Elves will want to turn this into a hiking trail. The beginning isn't very scenic, though; perhaps you can find a better starting point.
To maximize exercise while hiking, the trail should start as low as possible: elevation `a`. The goal is still the square marked `E`. However, the trail should still be direct, taking the fewest steps to reach its goal. So, you'll need to find the shortest path from *any square at elevation `a`* to the square marked `E`.
Again consider the example from above:
```
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi
```
Now, there are six choices for starting position (five marked `a`, plus the square marked `S` that counts as being at elevation `a`). If you start at the bottom-left square, you can reach the goal most quickly:
```
...v<<<<
...vv<<^
...v>E^^
.>v>>>^^
>^>>>>>^
```
This path reaches the goal in only `*29*` steps, the fewest possible.
*What is the fewest steps required to move starting from any square with elevation `a` to the location that should get the best signal?*

41
2022/12/input.txt Normal file
View File

@ -0,0 +1,41 @@
abcccccaaaccccaacaaccaaaaaaaaaaaaaaaaaaaaccccccccccccccccccccccccccccccccccaaaaaa
abcccccaaaacccaaaaaccaaaaaaaaaaaaaaaaaaaaacccccccccccccccccccccccccccccccccccaaaa
abcccccaaaaccaaaaaccccaaaccaaaaaacccacaaaaccccccccccccccccaaaccccccccccccccccaaaa
abcccccaaacccaaaaaaccccccccaaaaaacccccaaccccccccccccccccccaaaccccccccccccccccaaaa
abcccccccccccccaaaacccccccaaaaaaaaccccccccccccccccccccccccaaacccccccccccccccaaaaa
abccccccaacccccaacccccccccaaaaaaaaccccccccccccccccccccccccaaaaccaaacccccccccccccc
abccccccaacccccccccccccccaaacccaaaacccaacaaccccccccccacaccaaacaajaacccccccccccccc
abcccaaaaaaaaccccacccccccaaaccccaaacccaaaaaccccccccccaaaaaaajjjjkkkccccccaacccccc
abcccaaaaaaaacaaaacccccccccccccccccccaaaaaccccccccciiiijjjjjjjjjkkkkcaaaaaacccccc
abcccccaaaacccaaaaaacccccccccccccccccaaaaaacccccciiiiiijjjjjjjrrrkkkkaaaaaaaacccc
abcccccaaaaacccaaaacccccccccaacccccccccaaaaccccciiiiiiiijjjjrrrrrsskkaaaaaaaacccc
abccccaaaaaaccaaaaacccccccccaaaacccccccaccccccciiiiqqqqrrrrrrrrrssskkkaaaaaaacccc
abaaccaaccaaccaacaacccccccaaaaaaccccccccccccccciiiqqqqqrrrrrrruussskkkaaaaacccccc
abaaaacccccccccccccccccccccaaaaccccccccaaaccccciiqqqqqttrrrruuuuussskkaaaaacccccc
abaaaacccccccccccccccccccccaaaaaccccccccaaaaccchiqqqtttttuuuuuuuussskkcccaacccccc
abaaacccccaaaccacccccccccccaacaaccccccaaaaaaccchhqqqtttttuuuuxxuussslllcccccccccc
abaaaaccccaaaaaacaaccccccaccccccccccccaaaaacccchhqqqttxxxxuuxxyyusssllllccccccccc
abacaaccccaaaaaacaaaaaaaaaaccccccccccccaaaaaccchhqqqttxxxxxxxxyuusssslllccccccccc
abcccccccaaaaaaacaaaaaaaaaccccaacccccccaaccaccchhhqqtttxxxxxxyyvvvsssslllcccccccc
abcccccccaaaaaaaaaaaaaaaaaccccaaaaccccccccccccchhhppqttxxxxxyyyvvvvsqqqlllccccccc
SbcccaaccaaaaaaaaaaaaaaaaaacaaaaaacccccccccccchhhhpptttxxxEzzyyyyvvvqqqqlllcccccc
abcccaaccccaaacaaaaaaaaaaaaacaaaaccccccccccccchhhppptttxxxyyyyyyyyvvvqqqlllcccccc
abaaaaaaaacaaacaaaaaaaaaaaaacaaaaacaaccccccccchhpppsssxxyyyyyyyyvvvvvqqqlllcccccc
abaaaaaaaaccccccccaaacaaaccccaacaaaaaccccccaagggpppsswwwwwwyyyvvvvvvqqqmmmmcccccc
abccaaaaccccaacaacaaacaaacccccccccaaacaaaccaagggppssswwwwwwyyywvvqqqqqqmmmccccccc
abcaaaaaccccaaaaacaaccaaccaaaccaaaaaaaaaaaaaagggppsssswwwswwyywvrqqqqmmmmcccccccc
abcaaaaaaccaaaaacccccccccaaaaccaaaaaaaaaacaaagggpppssssssswwwwwwrrqmmmmmccccccccc
abcaacaaaccaaaaaaccccccccaaaaccccaaaaaacccaaagggppppssssssrwwwwrrrmmmmmdccccccccc
abccccaaaccaaaaaaccccccccaaaaccccaaaaaacccaacggggpooooooosrrwwwrrnmmmddddcacccccc
abccccaaaaaaaacccccccccccccccccccaaaaaaaccccccggggoooooooorrrrrrrnnmdddddaaaacccc
abcccccaaaaaaccccccccccccccccccccaaacaaacccccccggggfffooooorrrrrrnnddddaaaaaacccc
abccaaaaaaaacccccccccccccccccccccaccccccccccccccggffffffooonrrrrnnndddaaaaaaacccc
abccaaaaaaaaaccccaacccccccccccccccccccccccccccccccfffffffoonnnnnnndddcaaaaacccccc
abccaaaaaaaaaacccaaccccccccccccccaccccccccccccccccccccffffnnnnnnnedddaaaaaacccccc
abcccccaaaaaaaaaaaacccccccaccccaaacccccccccccccccccccccfffeennnneeedcccccaacccccc
abcccccaaacccaaaaaaaaccccaaacccaaaccacccccccccccccccccccafeeeeeeeeecccccccccccccc
abcccccaaccccaaaaaaaaacccaaaaaaaaaaaaccccccaaaccccccccccaaeeeeeeeeeccccccccccccca
abaccccccccccaaaaaaaaacccaaaaaaaaaaacccccccaaaaacccccccaaaaceeeeecccccccccccaccca
abaccccccccccaaaaaaaaccaaaaaaaaaaaaaacccccaaaaaccccccccaaaccccaaacccccccccccaaaaa
abaccccccccccaaaaaaacccaaaaaaaaaaaaaacccccaaaaacccccccccccccccccccccccccccccaaaaa
abaccccccccccaccaaaacccaaaaaaaaaaaaaaccccccaaaaaccccccccccccccccccccccccccccaaaaa

107
2022/12/python.py Normal file
View File

@ -0,0 +1,107 @@
# ah yes working on visualization
# WIP!!!!!!!
# (the puzzle is solved though)
from collections import deque
import time
from aocd import submit
with open("input.txt") as f:
lines = list(list(map(ord, line)) for line in f.read().splitlines())
for i, line in enumerate(lines):
try:
j = line.index(ord('S'))
S_pos = (i, j)
line[j] = ord("a")
except: pass
try:
j = line.index(ord('E'))
E_pos = (i, j)
line[j] = ord("z")
except: pass
dq = deque()
def walk(reverse=False):
if reverse:
dq.append((0, E_pos[0], E_pos[1]))
visited = [E_pos]
else:
dq.append((0, S_pos[0], S_pos[1]))
visited = [S_pos]
while dq:
yield dq
n, row, col = dq.popleft()
u = (row-1, col)
d = (row+1, col)
l = (row, col-1)
r = (row, col+1)
for newr, newc in u, d, l, r:
if (newr, newc) in visited:
continue
if newr < 0 or newc < 0 or newr >= len(lines) or newc >= len(lines[0]):
continue
if reverse:
# Part 2
if lines[row][col] - lines[newr][newc] > 1:
continue
else:
# Part 1
if lines[newr][newc] - lines[row][col] > 1:
continue
if reverse:
if lines[newr][newc] == ord('a'):
return n + 1
else:
if (newr, newc) == E_pos:
print(n+1)
return n + 1
dq.append((n+1, newr, newc))
visited.append((newr, newc))
# don't break here, so other possibilities are kept in deque
# print(result := walk())
# submit(result, "a", 12, 2022)
# print(result := walk(True))
# submit(result, "b", 12, 2022)
if __name__ == '__main__':
from curses import wrapper
logf = open("log.txt", "a")
def tui(stdscr) -> str:
# while stdscr.getkey() != 'q':
for q in walk():
logf.write(str(q) + "\n")
time.sleep(0.1)
stdscr.clear()
stdscr.refresh()
n_list = []
for i, line in enumerate(lines):
for j, o in enumerate(line):
ch = chr(o)
for n, row, col in q:
n_list.append(n)
if i == row and j == col:
stdscr.addstr("_")
else:
stdscr.addstr(ch)
stdscr.addstr("\n")
stdscr.addstr("n_list: {n_list}")
wrapper(tui)
logf.close()

5
2022/12/test.txt Normal file
View File

@ -0,0 +1,5 @@
Sabqponm
abcryxxl
accszExk
acctuvwj
abdefghi

160
2022/13/README.md Normal file
View File

@ -0,0 +1,160 @@
\--- Day 13: Distress Signal ---
----------
You climb the hill and again try contacting the Elves. However, you instead receive a signal you weren't expecting: a *distress signal*.
Your handheld device must still not be working properly; the packets from the distress signal got decoded *out of order*. You'll need to re-order the list of received packets (your puzzle input) to decode the message.
Your list consists of pairs of packets; pairs are separated by a blank line. You need to identify *how many pairs of packets are in the right order*.
For example:
```
[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[[1],4]
[9]
[[8,7,6]]
[[4,4],4,4]
[[4,4],4,4,4]
[7,7,7,7]
[7,7,7]
[]
[3]
[[[]]]
[[]]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[1,[2,[3,[4,[5,6,0]]]],8,9]
```
Packet data consists of lists and integers. Each list starts with `[`, ends with `]`, and contains zero or more comma-separated values (either integers or other lists). Each packet is always a list and appears on its own line.
When comparing two values, the first value is called *left* and the second value is called *right*. Then:
* If *both values are integers*, the *lower integer* should come first. If the left integer is lower than the right integer, the inputs are in the right order. If the left integer is higher than the right integer, the inputs are not in the right order. Otherwise, the inputs are the same integer; continue checking the next part of the input.
* If *both values are lists*, compare the first value of each list, then the second value, and so on. If the left list runs out of items first, the inputs are in the right order. If the right list runs out of items first, the inputs are not in the right order. If the lists are the same length and no comparison makes a decision about the order, continue checking the next part of the input.
* If *exactly one value is an integer*, convert the integer to a list which contains that integer as its only value, then retry the comparison. For example, if comparing `[0,0,0]` and `2`, convert the right value to `[2]` (a list containing `2`); the result is then found by instead comparing `[0,0,0]` and `[2]`.
Using these rules, you can determine which of the pairs in the example are in the right order:
```
== Pair 1 ==
- Compare [1,1,3,1,1] vs [1,1,5,1,1]
- Compare 1 vs 1
- Compare 1 vs 1
- Compare 3 vs 5
- Left side is smaller, so inputs are in the right order
== Pair 2 ==
- Compare [[1],[2,3,4]] vs [[1],4]
- Compare [1] vs [1]
- Compare 1 vs 1
- Compare [2,3,4] vs 4
- Mixed types; convert right to [4] and retry comparison
- Compare [2,3,4] vs [4]
- Compare 2 vs 4
- Left side is smaller, so inputs are in the right order
== Pair 3 ==
- Compare [9] vs [[8,7,6]]
- Compare 9 vs [8,7,6]
- Mixed types; convert left to [9] and retry comparison
- Compare [9] vs [8,7,6]
- Compare 9 vs 8
- Right side is smaller, so inputs are not in the right order
== Pair 4 ==
- Compare [[4,4],4,4] vs [[4,4],4,4,4]
- Compare [4,4] vs [4,4]
- Compare 4 vs 4
- Compare 4 vs 4
- Compare 4 vs 4
- Compare 4 vs 4
- Left side ran out of items, so inputs are in the right order
== Pair 5 ==
- Compare [7,7,7,7] vs [7,7,7]
- Compare 7 vs 7
- Compare 7 vs 7
- Compare 7 vs 7
- Right side ran out of items, so inputs are not in the right order
== Pair 6 ==
- Compare [] vs [3]
- Left side ran out of items, so inputs are in the right order
== Pair 7 ==
- Compare [[[]]] vs [[]]
- Compare [[]] vs []
- Right side ran out of items, so inputs are not in the right order
== Pair 8 ==
- Compare [1,[2,[3,[4,[5,6,7]]]],8,9] vs [1,[2,[3,[4,[5,6,0]]]],8,9]
- Compare 1 vs 1
- Compare [2,[3,[4,[5,6,7]]]] vs [2,[3,[4,[5,6,0]]]]
- Compare 2 vs 2
- Compare [3,[4,[5,6,7]]] vs [3,[4,[5,6,0]]]
- Compare 3 vs 3
- Compare [4,[5,6,7]] vs [4,[5,6,0]]
- Compare 4 vs 4
- Compare [5,6,7] vs [5,6,0]
- Compare 5 vs 5
- Compare 6 vs 6
- Compare 7 vs 0
- Right side is smaller, so inputs are not in the right order
```
What are the indices of the pairs that are already *in the right order*? (The first pair has index 1, the second pair has index 2, and so on.) In the above example, the pairs in the right order are 1, 2, 4, and 6; the sum of these indices is `*13*`.
Determine which pairs of packets are already in the right order. *What is the sum of the indices of those pairs?*
\--- Part Two ---
----------
Now, you just need to put *all* of the packets in the right order. Disregard the blank lines in your list of received packets.
The distress signal protocol also requires that you include two additional *divider packets*:
```
[[2]]
[[6]]
```
Using the same rules as before, organize all packets - the ones in your list of received packets as well as the two divider packets - into the correct order.
For the example above, the result of putting the packets in the correct order is:
```
[]
[[]]
[[[]]]
[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[1,[2,[3,[4,[5,6,0]]]],8,9]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[[1],4]
[[2]]
[3]
[[4,4],4,4]
[[4,4],4,4,4]
[[6]]
[7,7,7]
[7,7,7,7]
[[8,7,6]]
[9]
```
Afterward, locate the divider packets. To find the *decoder key* for this distress signal, you need to determine the indices of the two divider packets and multiply them together. (The first packet is at index 1, the second packet is at index 2, and so on.) In this example, the divider packets are *10th* and *14th*, and so the decoder key is `*140*`.
Organize all of the packets into the correct order. *What is the decoder key for the distress signal?*

449
2022/13/test2.txt Normal file
View File

@ -0,0 +1,449 @@
[[[[],3],[5,[1],[8,5],10,[5,8]]],[],[1]]
[[9,[4,9]]]
[[[[0,5],0],[[2]]],[7,[4,[2]],3,3],[[[],5,5,[4]],1,[0,[0],[9,10,5,5],[2,2]],2]]
[[[6,[1],3,[9,3],10],1,[[],[3,7,7,5,5]],6]]
[[0,[0],6]]
[[9,1,5,[]]]
[[0,[[],[]],[[0,2],[8,4,1,6],5]],[[0],[9]]]
[[0,2,9,5]]
[[]]
[[1,[0,1,[0,1,3,8,7]],5,1],[[[8,8],4]],[[[2,2,6],6],[[4,2,8,8],[1,6,2,8,6],2,7],5,7,[0,3,3,[4],[7,8,6,0,4]]],[[[4,0,7],9,4,0,7],[6],4],[6,6,[[7]],2]]
[[[6,[7,5,2,0],[7,1,3],[8,9,7,5,7]],[4,4,[8,9,10,7,6],[7,5,7,7,1],8],3,[7]]]
[[[10,2,[5,7,10,3]]],[4,[],[],1]]
[[[[1,2,2,10],0,[]],1,[],[],4]]
[[9,1,5],[],[[[4,7,1,3,6],[2],[4]],[5,[9],[3,9]],[],[2,7,9],7]]
[[[],4,[],5],[]]
[[1,[[9],[0],10],6,4],[[9,0,[1,4,1,0,4]],[],4,[2,[2,10,7,9,8],7]],[],[9,[],[[3],3,[]],[]]]
[[],[6,3],[[[9,7,5]],[[9,9,4,5],[2,9,6,10,3],[10,9,0,7,4]]],[[[0,4],10,3,[3,7,2,1,3]],1,[9,6,9,[1,7,3,6]],2,7],[8,[6],[[6,5],7]]]
[[[],[9,8,9,[0,8,5,2,5],[1,3,0,9,1]]],[[[2,10,5,2,2],[0,0,1,9],9,2,[1,1,8,8]],10,8,[[4,7,1,2,10],3,[],[7,0,0,4]],4],[[10,[3,6,8,4]],[]],[2,[[1],1]],[[[9,8,2,3],[3]],1,[[6,2,9,8,9]]]]
[[[2,[]]],[],[9,1]]
[[0,7,7,[1,[3,8,10,8],[3],[2,2]],10],[[0,5,[1,2],[0],[5,7,5]],1,4,[2]],[]]
[7,6,8,9,6]
[7,6,8,9]
[[[2,3,[7,7,1,6,2]],[7,[5,0,10,9]],5,[8,8,[7,3]],[10,[]]],[[6,[],0,[1,10,5,6]],4,0,[2,1]],[4,[[],[4,0,3],7],0,3,6],[9],[8]]
[[4,4]]
[[[[4,10,8],[4,3,3,6,4],[3,9,6,4,6],[3,10,4]],7],[7,0,5,[[3,6,0,1,3],[5,1],10,[5,6,8],[3,1,2]],5]]
[[],[[[7,5,0,2],0,[1,1,1],[9,5,7]],[6,7],[[1,10,3,6,10],7,4],8,9],[5,7,[],6,[10]],[[],2,[7,[0],10]],[[[0,5,8],[7,6,0],[],[2,7],9],[1,[10,9,1]],5,[[1,0,2],10,8],[7,9,[7],1,9]]]
[[[[],2,3],[2,3,[],[5,9,10,4,9],[6,1,2,9,4]]],[3,1],[6,2,9,2,[10,[2,3,3,3],[3,6,4],[]]],[8,[[3,9,4,1],8,[4,0,10,5,4],[4,7,8],5],[[6],[2,7,5],[7,8]],[],[1,3]]]
[[8,4],[]]
[[],[],[1],[0,4],[5,4,2,[8]]]
[[1,[[5],[5,5,4],[2,4],0],10,[4,2],[6,[],[10],6]],[[[4,9],10,[10,1,2,10],3],1,[],[[4,9,5],6,[5,7,4,3,5],9,2]],[]]
[[6,8],[2,[],9,[[7,3,3],4,3,9,5]],[[10,2,0,1,[8,1]],0,3,[0,7,1]],[3,[[6,3]],[[1,7,9,8,8],4,9,4,10]]]
[[3,5],[[[5,7,10,6],[4,1,8],[4,0,5]]],[[0,[8,2],6,2],2]]
[[8,1,8,[[6,10,7,5],[6,7,0,3],1]],[[[8,4,5],6],5],[4,[3,0]]]
[[0,[],0,10,[4,4,[7,8,4,9,3],[],[2]]],[6,10]]
[[],[],[],[[[6,9,6,5,7],[],[]],[6],[[7,0,6,1]],6]]
[[[[],1,[6,5,5]]],[[[6,7,3,0,4],[9,6],7],5,2,1],[[1,[1,0],10]]]
[[],[[],4,[9,[2,5,6,3],7,[10,7,9]],[[4,0,2,1],[]]]]
[[],[9,7,7],[7],[[[7,8],8,[10,4,2,9,0],[3,9],7],1,[4]]]
[[[],[[7,0,7,8,5],8,8],[2,[1,0,1,10,8],9,2]],[[7]],[4,8,4,6]]
[[[[4,2],[8,8,10,4],6],5,3,[[7,9,4,6,6],10,6,7]],[],[]]
[[[[2,7,10],[],2],[[0],1,[8,10,9,9,6]],10],[],[[[6,2,7],[],7],3],[1,3,10,[[0,4,7,6],[3,1,4,6],10,8,[4,1,5,2]],7]]
[[[1,8,[8,6,9,8,6],3,[6,10]],7]]
[[4],[],[[[3,7],6,8],[1,[10,7,10,5],[1,9,10]],2,9]]
[[[[0,1,10,9],[9],[9],[]],3],[10,3,0]]
[[[[2,1,4],[5],[7],0,[4,7]],0,7,7,8],[[8,8],[],[[],[0,3,8,2,3],[3,6,6]],[10,4,4,5,[]]],[10,[8],[],[[],[4,2],[4,9]]],[[[0,7,6,8],[3,2,3,4],[9,0,1,4,7],[2,8],[4,1]],[1,[8],[3,9,10,5,8],1,4],6,3]]
[[6,7,9,[2],4]]
[[6,4,4,[[],9],1],[10,[4,[4],0],[],[4,[4,2,1,1,4],2,1]],[3]]
[[8,[4,[],4,3],5,9],[[5,[]],0]]
[[1,[10,5,2,[]],[10,2,8,[1,6,10,8]],7,7]]
[[[[0,4,4],[7,5,2,9,7]]],[9,8,[]],[5,[]],[[],1]]
[[8,4],[10,2,8,[5,4,5,[8,3,4,3,6],[9]],[1]]]
[[6,[[0,4,10,4],[9,4,6,6,7],[0,0,1],[4,3,1,1,7],3],[[0,9,8],3]],[[5],[[7],[0,4],4,0,[9]],1,[6,6,[8,2],[2,1,3]],9]]
[[0,[9,5,5],0],[[[7],[0,8],[1,0],[],[2]],5,[[0,6,8],9],[[1,6,5,8]],[[9,5],[4,4,7,0,7],1,10]],[[2]],[6,6],[[[8,7,5,3],3,7],[3,[],[10,4,5,1],[9],[2,9,4]],[[10,6,2,2],[0,0,6],[4,7,6,10,8]]]]
[[[5,[1,10,1,7,1],[8,0]],[[0,5],[],[0,8,2,3],[2,3,10,7]],3,10,8],[],[[10,8,4,2,[1,8,5,7,9]],5,9]]
[[[],7,1,[4,6]],[1,[[4,0,8,0],[0,10]],7,6],[3,[[6,0,3],10,3,7]],[[[4],7],3,[]]]
[[9,3,6]]
[[9],[[10,[7,1,0,0,1],[0,2,4,0],10,[3,10]],2,[[8]]],[10,7,[5,[],5],4,9]]
[[[[4,2,4],[],7,3]],[7,4,3]]
[[[[5,1,5,8],[5,2,5],1],4],[[2],[[8,3,4],5,[0,10,10,6,10],0]],[5,8,[[10],[10,8],10,2,7],[[4,6,2,3,4]],[]],[10,[],0,[[5,0],1,3,3,[]],[0,[6,2],8,7]]]
[[10,0],[[[2,10]],3,3,10,[8]],[],[4],[[[10,10,1],[6,3,7,8,4],3,[4,6],8],[[5,2,2],0],[],[[],2,[5,4]]]]
[[3,7],[5,2],[],[6,[[4,3,7]]]]
[[[[3,7,2,5],8],[[],[5,9,3,9]]]]
[[[[8,1,7,6],[9,4],[8,1,5]],6,[[3,4,0],8,[4,9],[],9],9],[0,[[6,7],[4,1,6,3,1],1,[8,4,9]],[8,[3,3,3]],0],[]]
[[[],3],[[[]],9,4,3,3]]
[[[[]],10],[[[1,9,6,1,8],5],1,0,10,[[0,0,0],[2],5]]]
[[2],[[[0,2,7],1],3,6],[]]
[[],[[4],2,[10]],[4,[[1,5,10],[6,9,4],6,4,[0,8,8,8]],[10,3,2],[10,9,2,[8,2,6,6,5]]]]
[[[10,[],[0,1],[],4]],[5,[],6,6],[[],[7,[],[1,1,7,7,4]]],[5,10,2],[]]
[[9,[[10],8],[8,7,5,3,[0,1,3,10,5]],1,[[6,5,10,0],10,[9,10,10],4]],[9,4,9,4,10]]
[[[7,[6,0,8,3,5],[9,0],[0,8,0,7],[9]],[[8,5,10,9],3,[],[9,3,6]],[],5],[[9],[[6,10],9,0,9,[4,9,6]]],[1],[[8],3,9]]
[[7],[[]],[8,[[0,2],1,[5,7,2],8,0],6,4]]
[[4,8],[[[],[4,6]],5,6,[[3,8,4,8,5],4,[7,9,8]],2]]
[[],[[2,[10],[9,9,2,3]],8,2,6]]
[[],[[],[3,[10,4],[10,5],2],8],[[9,6,3,9],[6,2,[],9,2],[10,10],7,8],[[5,[9],[0],3],9],[[3,5,[]],[]]]
[5,0,5,7]
[5,0,5,7,8]
[[],[1,[]]]
[[],[6,[[8,4,9]],[[4,2]]],[6,[[2,0,0,7],1,8]],[[],[[4,3,8,6],4,1]],[10,5,1,8,[]]]
[[[10,[6,9,7],4,6,[0]]],[[[8,5,1],[7,5,3],[2],8,[4,6]],6,[10,2,[],8],2,3],[[10,4,1,[]]]]
[[[1,4]],[[],[[1,5,6,2],6,9,[]],9,[6,4,1]],[3,2],[[[],1,4,[2]],[[2],8,[3],9,10],4,[[],9,[1,1],6,[3,7]]]]
[[[[0,6,0,10,4]],10,4],[8,5],[4,[8,5],[9],0,[9,3,[]]]]
[[2,[0,[8,9,9],9,[2,9]],1,8],[[7,[8,10],5,2],0,3,[8,7]],[[[],[2,4],[8,4,4,0],3,3]],[[6],4,9,7,[]],[[4,10],[[9,8],[4,3,4,9],5],[8,[],9],1,[[7],7,5,1]]]
[[[8,1],3],[[4,[0,0,3,2,4],10,[],6],0,8,[[6,2,6,2,7],8,[2,0,7,2],0,[9,5,3,6,4]]]]
[[],[[[]],[[0,8,5,9,9],[6,9],6],1,[3,10]],[7,[],[2,3]],[[[2,3,6,0],6],[],8],[8,8]]
[[[]],[7,0],[4],[5],[]]
[[[],[5,6,7,[2,6,3]],3,5],[],[],[[[7,6,6],[],[10],[0]],3,2,[9,[3,2,3],[2,6,10,1,2],[8,2,0,4,0],10],9],[[[4,5,0,2,7]],[9,[2,7],8,0,[2,9]],[[],9,[1,0],[8,6],[1]],[],[]]]
[[[],2,[[10,7,6,6],[10]]],[4,9,[],[[4,1,5,9,0],[5,6],2]],[8,[],[5,0],[],[6,4]]]
[[],[],[],[]]
[[[0,3,[10,10,8,2,1],[5],[8,4]],[9,1,[10,2,3,9],7],[6],[[3,3]],[]],[3,1],[]]
[[4,[],[],[9,9,3],[[9,2],2]],[8,1,4,1]]
[[],[],[6,1,[[8,0,7,10,6],[8],1,[9,7,1,9,10],9]],[3]]
[[[[4,2,0,9],10,[8,2],5],2,5,0,[[7,4,7,6],10]],[2,2],[],[6,[[9,2]],[],[[3,2,4,5]]]]
[[1],[2],[5,0,[]],[[[6],0,[1,5]]],[5,7]]
[[2,1],[1],[7]]
[[[9,6,[10,6,3,5,10],8]],[0,[[7,2,3],1,5,4],[[7,3,10,1,4],8,[9,5],[4]],3,[[10,4,4]]],[[],[[]]]]
[[6,3],[4,[6,[1,4,2],[4],[9,2]]],[],[]]
[[[9],[[1,4],[9,0],[3,8,1,1],0,[]],5,[0,[1,3,8],10,6]],[],[[[9],4,0],8]]
[[],[7]]
[[[9,10,4,[10],2],0]]
[[],[4,3,2,6],[[[9,5],[]],4]]
[[5,4],[[3,[]],[[4,9,5,7,1],[0,6,5,8,7]]],[10,0]]
[[[[],0,[5,4,3,1],8],3,[8],7,[[1],6,6,[0],1]],[1]]
[[],[],[[1,[9]],8,4,2,[10,[10,10,2],1,1,5]],[4,[2,2,6],[[5],6]]]
[[8],[],[9,[],3],[[[8],0,[10],[4,0,5,5,0],[8,9,5]],[[],8,[9,5]],10,1],[10,3,4]]
[[],[],[10,[2,[6],[6,10,9,9],[2,10,6,0],10]],[10]]
[[3,[5],[[1],1,2],[5,8,[9,10]]],[1,3,6],[[[7,6,6,8],5,1,[6,6]],[[9,10,2,5]]],[],[[9,0],6]]
[[],[5,[7,8,9,[10]],5],[0,9,[],[5]],[9]]
[[4,9,6],[[[6,0,1],[1],[0,10,0,9,5]],[],[],8],[[[0,9,1],[7,2,1]],6],[[10],0,2,[1,5,[2]],[8,[1,8],4,[9,3,1],5]],[8]]
[[[5,0]],[1,3,[[10],[6,7]],9,1],[3,[],5,[],[[9,0,10,0],1,8,5]]]
[[9,7],[],[3,[[3,10,1,6,7]]],[],[[[7,7,4,9],7],6]]
[[[3,4,[4]],[],6,[8,[2,7],[3,8,2]]],[],[[6,[8,6,0],[8,8]],0,0,[[4,0]],[[3,5,8,3]]],[]]
[[1,[[1],[7,7,8,2],2,5,1]],[]]
[[[6,[1,9],[1,10,4,8,9],6],0,[[6,0,7,5,0],[1,5,0]],6,8]]
[[[[],0,[],[4,9]],[9,[3,1,1,10],1,[10,8,3]],4,[[],3,3,[],[2]],[[8,10,9,4,7],10,9,1,[10,10,9,5,3]]]]
[[[3,[9,0]],[0,[7,7,4,10,6],[2,10,1,3]],[10,[4],1,1],[[2,0,3],[]],[[5],[4],[],2,[6,3,5]]],[[[],[5,7,9],1,[2],4],9],[1,9],[[[],[4,1]]]]
[[[]],[7,[],[[7,7,10],7,[4,8],[6,9],[8,8,4,4]],[8]],[5,1,8,[[],4,3,8,1]]]
[[[7,[8,6,2,0]],[7],10],[[[3],2],0],[4,10,5],[1,9,7,4]]
[[],[[[6,4,1,0],8,1,[6,7,8,6]],0,[],[6,[0,7,6]]],[[8,1,[6,8,5,8,1],[10,7,7,5,10],[5,4,3]],3,[6],[[4,3,3,8,5],5],[7,[4,1,4],2,0,2]]]
[[[2,5,[8,4],[1,2]],2],[[],[],[],1,[]]]
[[9,[],7]]
[[[1,[7,5,5],2,[3,1,5]],[[1],4,5,[9,10]]]]
[[2,[[]],10]]
[[9,6,[10,[0,5],9,6]]]
[[3,[[5,6,5,10]]],[[5,[9,1,0,6,10],[9]],[],1,5,8],[[3],[0,[],[8,7,1,0,2],[4,4],0],[[],[],8,[7,8],6],1,[2,0,[5,7,0,7],[2]]]]
[[[[9],[]],8],[],[[[],9,[5,3,7,7,10],[6,9]],5,3,0],[[1],[[6],6,[9,5,0,8],6],10]]
[[[4,10],6,4],[[10],[5,[2,5,0,10],[3,4],[6,2]],3,[[3,7,1,5,1],7,3,[6,4],0],2],[6,[7,[3],7],8,[3,[1,8],[4,2,6,2,2],[]]],[8,4,7,[[3,7],[4,0,9,2,9],[7,7,1,6],9,[0,8]]],[[10,2,[3],1,10],[7,7,[3,5],5,7],[4,[7,10,1],1],[[8,2,0,8,2],[10,5,6,5,9],[3,9],[4],[6,6,0,5,2]],[5,[9,9],[7,3],4]]]
[[],[[[7,0]]]]
[[[],[[1,4,6],10,6],[6,6],1],[0],[[[1]],1,[[2,4],1,2],0],[],[[[9,5],[],3,[10,3,10,9],7],[9],4,[5]]]
[[[7,[1,10,3]],2,[]]]
[[8]]
[[[[5,2,3],5],[[9,7,6],[2],6,[8]]],[1,[[4,1],[10,4,4,9,1],2,3,3],[[1,3],[1],[9,0,1],[5,5,8]],0,1],[[[2,6,5,2,5],[4],0,2],5,10,[]],[3,7]]
[[[],8],[[[],5],[[10]]],[[[5,5,6],5],4]]
[[7,[[],6,[6]],7],[8,5,8,[0,[8],2,[4,5,10,7],7],6]]
[[10,6,[],7,[[8,0,0,6,3]]],[3,6],[8,[9,[2,7],[6,9,5],[5,6,7,1,3],2],1,[[3,1,4,7,0]]],[[[7,8,8,0],[6,5,8],[2,8,3,10]],[[8],[10,6,3,3],1],[[8,5,3,10],[10,9,10,8,8],[3,3,5,8,2]]],[[]]]
[[5,[4],[[8,9,1,8,3],[1,5]],[]],[2,2,10,[4,10,[1],7,[]]],[8,[[10,7,9,8,7],5,[1,10],7,[1,9,8,6,1]],[],3],[],[0,[[4,6,4,10],[5,1,3,3],[1]]]]
[[6],[[],[1],[7,9,4,10,5]],[[4,[2,1,10,6],4],10,8,4,[7,0,3,6]],[[4,[3,7],1,[3,9,8,1,5]],1,[4],[[1,3,0,7,5],[5],3]]]
[[1,0,4,[10,[4],[],[9,8,4],[0,4]],[[8],[6,3],7,0,0]],[[4,10,[0,1,9,8,3]],7,8],[5,0,[],4],[1]]
[[],[],[7]]
[[8,5,6,1],[6,[3],4,7],[],[]]
[[[[9,0,4,2,6]],[10,4,[4],0]],[9,5,[],[],[5,[],3,10,1]],[[[1,10],5],[],7],[],[]]
[[[[0,10],7,[1],[0,2]],2,7,[[5,8],[6,0,10,2,1],[8,2,6,10,8],[2],10]],[[[7,6,10,7],10,0],[[3,3]],6],[[[]]],[[[10,8,1]],[],[9]],[[],1]]
[[9,6,[[2,9,10,8],[7,7,8,9],[4,1],[9,2],7],[3]],[[[4,3],8,1,8,4]],[3]]
[[8,3,[7,[8,0],2,[2,5,3,8,0]]]]
[[3,4,2,8],[[9,[0,8,6,9,2]]],[[5,6,4,[10,9,8,5],[5,6]],[2,[],8,[1,3,8,8,4],[1,7,4,0,4]],[2,2,[2,8,5,6]],[6,3],2]]
[[[3,[2,3,3],8,[9,8],[8,6,4,2]],[6,4,1,8],5,8,7],[10,10,3,9],[5,3]]
[[[],10,5,[1,[],[7,6],8],[[3,3,1,4,0],3,[1,7,10],7]],[]]
[[[0,[7,10,0],[],[0,0,0,7,4]],[[2,3],4,9,[1,1,3,2],[8,9,8,8]],3],[6,[[10,4,0,4,9],0,1,7,[5,6,0,0,9]]],[[[],[9,8,3,4]],[[5,9,10],9],5,6,2],[7,[[2,3,3]],[[3,7,7],[1]],1],[8,0,[0,8,2,[4,2,10],[2]],[[6,0,8],8,3],6]]
[[0,[[4,1]]],[1,10,9,3,8],[[[6,3,9],0,[2,6],[4]],7,10,9],[[[],9],8,[8,[1,0]],[0],[[5],7,9,[7],[]]],[[7,1,[],3,[]],5]]
[[[[1,10,3,6],10,8,5]],[[2,[0,6,7,1,5]],[],5],[[[],[5,5,9,5,8],[6,8,2]],[9,2,2],1]]
[[],[],[[0,1,[2,3,8,7],9],[],[5,[0,7,10,6,10],[0,1],9],[8,8,1,[8,4,2,3]]]]
[[[8,[6,7]],[3,1],[[],5,[9,2,5],[10],0]],[9,3,[[7],3,[5]],[]],[[4],0,0,7,[7,10]]]
[[[],4],[6,[[3,9,8,4],[0],[8],[5,8,10,10,8],[9,6,6]],0,[6,[4],[0,8,4,1],2,[8,8]],[9,[1,5],2,[3,6]]]]
[[1,[[9,3,4,6],7,[10,0,1],[1],[5]],[10,4,0,[]],[8,[1,7]],5],[4],[[10,[2,7,5,10]],[[8,0,3],6,[1,1,2,0,7]],6,1,[[6,0,3],2,5,[],[]]],[8,[[7,3,1],7]],[[[2],[5,8,8,2]],[0,[2,3,5]],0]]
[[[[10,0,10,8],2,[1,5,2,6],9,[]],[5]],[[3,1,[0,7],[2,6,2]],8],[[2],8,0,4]]
[[],[[7,1],[3,[4,4,3],1,1],[[2,0,3,6,10],7,[4,9,10,1]],4,[9,[2,6],1]],[2,[0,[],[4,8,9,2],[10,3]],[10,10]],[8],[7,8,4,[7],8]]
[[5,6,[],6,10],[[[7,8,1,0],[10,0],9,6],9,[[3],6],9],[]]
[[],[2,[],[]],[3,5,[[4],[7,7],4,[2,2,5],8],[[],[8,10]],[7]]]
[[5]]
[[3,5,[[5,8,4,0],5,1,[],[6,8,4,7,9]],9,9],[2,[0],[[6,10,1,9]]],[5],[],[[9,10,[],[8,10,6,8,3],3],[2,5],6,8]]
[[[2,[8]],[1,0],[5,10,[1]]]]
[[1,[[10,0],[],[3,4,2,8,10]]],[0,[5,9,[8,6],1,[0,3,10,0]],8,[[0,6],1,[9,8,9,5],2]],[4],[1]]
[[5,2],[10,[8,[2,6,10],6,1,[]]]]
[[[],0,[2]],[],[0,0,[[0,1,9],[2,8]],[7,[2,4,4,1],[7,1,0],[4,3]]],[[[]],7,9,10],[[],[],0,1]]
[[[9,[2,10,2,6],2,0],7],[[4,3,[6,7,0,4],1,[2,10,0,6]]],[[[9,1,4,3,7],5,[5,5]],10,[9],[[8,10],[4,8,6],10,[5,7,9,1,7],[8,7]]],[[[1],2,10],[[1],10]]]
[[1,6,[4,2,5,[3,5],8]],[[[9]]],[[[4,4,3,3,5],[3,5],[9,5,9],6]],[[10,[]],[],1]]
[[[8],[[5,8,9,8],1,4,0],[[],5,[],3,[9,0,9]],[[3,4,2,10],[4,9,6,10]],[9]]]
[[10,6,[4,8,[],[],[6,5,9,1]],[]],[[[8,9,0],3,[9],10],[[7],[1,10,8,2]]],[[],[],[[3,8,7,9,6],4,[9,8,8,8],[]],[[6,1,7,3,8],[4,9,5],10,0,[9,9,0,2]]]]
[[8,[],[[3,4,8,3]],8],[8,[9],[2,[9,0],[2,1,10],[3,1,2],[4,6,7,1]]],[[7],[],[],[[4,6,6,9,6],[9]],0],[[],[0,[]],0]]
[[10,0,4,[],7],[[6,10],5,4],[[6,1,5],7,[[10,10,1,2,7]],[[],[0],0,1,[7,7,1]],5]]
[[[6,4,[2,10],8],6,[7,7,8,[8],5],[],10]]
[[6,6],[8,1,[9],[[4,2,6,8,5],7,[5]],6],[[[],7,5,2],8,3,10],[[6,[],7,[1,0],[8,4,8]],[[]]]]
[[],[10],[[[2,3,0],2,7,4,[0,5,5,6]],[[0,5,9],[6,9,8,4],5]]]
[[3,[3,[],2],0],[[],10,[[9,3,9],[9,6,7,9,3],[0,0,3]],[[]],8],[[6,9,6,[9,7,7,7],[7]],1,5,[5,4,[4,6],7,[]]]]
[[4,[2,[],[1,9,5],10],6],[[],[[8,6,0,5],6,1],3,[5,[7,0],7]],[[[3],2,8,[5,4],[]]]]
[[[[0,6]],[[6,3,3,7,5],[5],6],[[8,8],[0,10,8,6],[]]],[3,3,[8]],[[[7,4,2],[10,4,5,9],0,3,[5]],3],[1]]
[[2,10,[[5,4,5,1,4]]],[9,0,[8],[[5,6,0,5],[6,7,5,3,4]],2]]
[[[[]],[[6,3,2,8,8],[10,9,6,2],[1],5],[[],6,[]],[[0,1,8,3],[6,1,2]],[]],[8]]
[[4,5,[]],[10],[0],[3,7],[0,[3,1,[5]],6]]
[[[10,1,0],[[9]]],[[[6],3,[],7],[[0],6,[8,9]]],[[3,[3]],[[2,5,8,10],7,[],[0,5,0,6]],[],[[2,2,1],[3,7],[],[8,9,1]],3],[],[2,1,[[10,3,1],2]]]
[[10,[[5,10,6]],4],[[10,6],9,2],[6,[[7,1,1],[6,0,6,10],[]]],[1,6,3,[],[[6,6,1],1]]]
[[2,[],[[10],9,[9,5,10,8],5,8],7],[10,8,1,6],[],[7,4,7,0]]
[[5,1,[0],6],[[[],[],9,2],[1,[10]],10,0]]
[[0,4,3],[[2,7,10],[[],[4],2],6],[[[10,6,4,6],0,4,2,[6]],[[],[8,7,1,5],[6,8,2,8],7]],[6]]
[[2,7,[[3,3,2],[8,5,8]]],[8,8,6,[],6]]
[[],[7],[7,8,8,1],[]]
[[9,[5,4,4]],[2,[[3,10,10,5],[5,5,1],[8],8,7]],[6],[3,8,[[1,2,8],9,2],[7,7,4,1,9],1]]
[[7,6,3],[],[5,2,6,9],[6,5,[0],[0,1,7,10],[4,[],8]],[[6],[7,6,6,[1]],5,6]]
[[[],[],2],[[2,6],10],[10,[[5,8,2,4]]],[0,6,3,10]]
[[],[[[7,8,10,10]],[],8]]
[[[5,[3,1,0]]],[[],6,[],[8,9,[2,9]],7],[[[],[4],[9,7,6,4],[4],[]],[7,4,3,1,[3,2,6]]]]
[[[[3,1,6]],8,[10,4,0],6],[7,0,3]]
[[[4],[]]]
[[1],[[[4,7,7]],1,0]]
[[],[3,10,[[3,7]]],[],[[1,1,7,8,[8,4,8,0]],[0,[9,4]],[0]]]
[[[9],4],[5,[[9,2,9,5,8]]],[[0,7],3,7,[[7,9,5,7],9,9],6]]
[[[[9,10,1,4,10],[1,9,8],9,5,[0,7,2,5]],6,[[6,0,5,1,5],0],7],[],[7,0,[[4,10,3,1,0],[10,5,8,1,7],3,0]]]
[[2,0,[[2,7],8,3,6,[0,8]]],[[[]],6,[[],[4,5,6,2],[2,9,1],0],2],[5],[[4,[2],[3,10]]]]
[[0,6,7,[3,7,[5,3]],[]],[],[4,6],[[[6,9],[]],[9,5,10]],[[1,10,0,[2,0,5,0]],[[],6,[4,2]],7,6]]
[[[0,6,[1,10],10],8,6],[[[],[0,9],1,[10,6],[6,8]],[10,0,[7,10],7,[9]],6,7,[3,1]],[[5,[9,10,0]],[6],2,[[3]],8],[[8,1,2,[9,3,6],[2,0]],[10,[],0,[2,6,10,5,5],7],5,3,8]]
[[[[9,6,8],[7,2,9,2]],1,8,[1,[8,1,4,1],4,1,[]],6],[5,4,[]]]
[[[],[4,4,[9]],5,[4],0],[]]
[[3,3,4,[5,[0,8,0,8,0],8],2]]
[[[6,1,10,[],3]],[[[9,3,2],[8,0,7,7,5],0],[]],[9,5],[],[[3,[7,4,2]],[[2,2,0,10],0,[1,1],10,2],5,0,[]]]
[[],[1,[9],[[5,2,4,6,1],7,[9,5],[8,1]],[[10],[6,5,3,3,5]]],[],[5,6],[[[],5,[8,9,1,8]],4]]
[[[8,8],[[7,0,2,7,4],[],1,[5,1],[5,8,3,1]]],[6,[6]],[8,[10]],[[6,[]],[[3,9,9,8],[7,8],5,1,10],[[4,8,3]],[]],[[],[10,[9],8,[6,9,9,5]],[[10,9,9,1,7],5,[9,0,3,4,5],[3,10,9,9,1]]]]
[[],[1,8,9,1,[5,[5,0,3,7]]],[8,[[2,2,1]],8,1]]
[[[]],[6,0,9,[2,5,5]],[[[],7,[10],3],[[2,9],[4],9,9],5,[],5],[]]
[[[4,[2,8,3],[2],[0,5]],0,7,[],3],[8]]
[[[4,5,0,9],1,6],[[[3,10],[2,2,5],8],[4,6,8,2],[[0,9,10,4],[5,9,7,8]]],[2],[9,4,[9,[6,5,1],[8,5],[2,10,4,8]],[[],8,[9,4],[6,8]]]]
[[],[[4,[7],[1,1,9],[7,3,7,7,0],[9,2]],[[10,1,3],6],[[],[4,4,10],2,8,[5,4]]],[[0,8,[],[8,1,0,9],5],[[4]],[8,[2,4,3],10,[6,0,7]],[3,9],10]]
[[],[[5,9,10],4]]
[[2,[[],[1,6,10]]],[2],[3,3]]
[[],[5,[],9,10]]
[]
[[1,1],[[[3,5],0,0],10,8]]
[[[],6,5,[],4],[8,3,[3,9,6,[0,7,4,6],[]],0],[[[7,8,7,6,4],[7,2,3,7,3]],[3,6],1]]
[[],[]]
[[8],[[]],[0,[2,4],[5]],[7,10,7,[]],[]]
[[[1,9,1,7,2],[[5,10,7],[4,0,7],[6,5,7],1]],[5,6,[1,[4,0],[7,4]]],[10]]
[[6,8,[0,[3,6,5,2],[8,4,7],5],[[4,5],[7,4,8],1,[10,6]],[[]]]]
[[[],3]]
[[],[4],[]]
[[6],[[[],[],[],[7]],2,[[6,5,9],10,[10,8,6]]],[[],5,[[10,4],0],4],[]]
[[4,5,[]],[]]
[[[6],[[3,0,5,7,8]],[[5,1,1,1,4],3,[8,0,6],6,1],0,9],[]]
[[[7,7,4]],[[8,6,[1,7],0],[],[3],6,[[0,7,2],[8,1,2,4,2],1]],[[9]],[[]],[[[9,5,1,9],6]]]
[[[],[[10,8],[2,9,8],[5]]]]
[[8,6,[[1,8,9,7],[9],5,0,[5,1,9,0,2]],[3,[1]]],[1,[3,5,0,1]],[[8,1,10,1,[6,0,9,0,8]],0,[0,6,[3,7,3,1,6],[7,9]]],[9,[[1,3,1,1],[8],[1,5],[10],[2,7]],[],[8,4],[[1,1,3,4,0],10]],[8,10,[6,10,2,8,6],10]]
[[2,[[6,0,2],[5,9,2,2,2],[0,2,1,2],0,[]],1],[0,3,0,8,[]],[10,[0,[0,6,4],[8],6],[],[],1],[0],[[]]]
[[],[[],6],[[5,[1,1,5,4,1],[0,7],[0,3,8,0],[0,8,7]],8,[[10,8,6,3,9],3,[],5]],[[5,6,[8,9]],10,10,[[1,1,1,0,9],[3,10,10,3],[10,9,10,2,5]],[]]]
[[[1,7,1,[5,1],[4,4]],3],[0,9,[[8,3,6,1,8],3,[7,10,4,9],7],[7]],[[3,[3,1,3,8],[9]]],[[10,[2,6,6,3,2],7]],[[],7,[],[]]]
[[],[[[5,0,7,0]],3,[[3],[10,8,6]],10]]
[[9],[8,6,4,[[7,2,7],10]],[[],[[3],2]],[],[7,5,6]]
[[4,[[5,10,7,1],3,[],[],5],[[4,9,4,1,0],[0,0,7],[8,7],3],[]]]
[[],[6,[[6,2,0,0]]],[[[6,5,3,4,5],[2,2,4,8],2],1,9,7],[2,1,[7,2,5,[4,4,0,1,10]],7],[[],0,[0,1,4,[0,4],0],3,5]]
[[9,10,[[7,8],[9,5,7,0,8],[2],[4]],[],[[2,1,7,8],9,[3,1,1,1],[4,9,4,2,1],1]],[[[],9,[9,1,7,2],[],[2]],6,8,[0],[10,2,3,10,[7,6,8,5,4]]]]
[[[1,1,10,[3,5,10],[9]]],[[3,[8,10,1,8,4],[4,3,10],2,3],[5,1],1,1,9],[[6,[],1,[8,6,2,9,8],[7,3]],[[],[3,7,4,7,2],[1,2,4,0],[0,4,8,6],[4,9,1]],7],[]]
[[1,2,[[9,0,5,10],2,4,[7,1,5,4,9]]],[9],[[[6,5],4],[[]],[[3],[4,10,4,10],7,[6,7,8,9,10],[]]],[]]
[[0,5,[[4,3,10,2,7],[7],[2,5],[],2]],[[5,9,7,8],[[3,3,1,6],[2,5,4],[4],[]],8,6,[[5,3,7],2,7,[2,1,8,0],9]],[10,[],[],[]],[[[1,5],[3,10,4,7],[]],[[]],[]],[5,2,[]]]
[[[[0,9,0,9,0],[3],10],[],[7,7,[3,4],7,8],5,[[7,0],[5,7,6,0,8],[],3]],[],[10,6],[[1,[6,8,10],[5,6,5,10,1]]]]
[[5,2,7,[[],8,[4,10]],[]]]
[[[6,[5,3,0,4,1],[0,0,9,2,2]],[[3,6,7,8],0,0,[5,10,6,1,6],[5,4,6,10,5]]],[[[6],[5,5,2,0,4]],2,10,8,6],[5,[5,7],2],[10,2,[8,[10,0,4]],5,[]]]
[[],[[],[8,[],[7,2,4,0,5]]]]
[[[[3]],[],[[9,7,9,9],6,5]],[6],[]]
[[],[4,3,[[6,5],[]],[[3],0,[10,2,1],[7,10,4,4]]]]
[[10,[5,7,8],[[10,8,8,5,4],[9],8],2,[6,[],7,3]],[[6,[7,3,1,10,1],[3,3,3,6,10],[]],0,1,[]],[[[2],7],3,5,3],[[1,[1],[10,9,8]],[],10],[4]]
[[[2,[6,6,6],0]],[0,1,[[3,1,7,5,0],2,[6,0],[8,2,1],[4]]],[[[10,6,0,5,1],[9,3,6]],[[3,10,7,9,9],[],[3],4,[]],10,2],[[3,[]],2]]
[[1],[7,1],[]]
[[[4,7,[4,4,10,4],[8,8]],10,[[4,9,10,3,5],[5,8],6,6,5],3,[[2],[3,7,5,4,8]]],[],[[8,0,[7],8],2,9]]
[[[[7,7,2,9,10],10,[1,1,10,9],[4,7,4],7],7],[8,[2,[9],1],8],[6,7,[7,[9,2,4,6],[6,6,0,10]],[0,7,10],9],[[[],5]],[[[5,1],[1]],[[],[6,9,6,9,7],[8,7,7,7,10],[7,2,2],5]]]
[[],[3],[[]],[7,10]]
[[2,[2,[2],9,3,[9,4,6,2]]],[],[7,[[8,0,7],[],[8,4,0],[3,6,2,3]],[[],[10,8,6],0],[[10],[6,3],4,4]]]
[[1,[1,9]],[[0,[3,8,9,10]],[2,[7,1]],8,[[],3,[6,2,6],[3,0,8]],3],[[[]]]]
[[[[6,3],[3,10,8,6,3],[9,9,10,0]],2,[[0,4,7,0,7],10,4],8,[[4,5,10],[9,5,4],3,4,7]],[[2,8,[],[5,3,3,4],7]],[],[]]
[[[1],2,1,[[4],[0,10,4]]],[[4],[],[[2],3,5,2]],[8],[[[1,4,10,10],10,[],0,4],[2,[9,6,7,2],[3,10,1,8]]],[]]
[[[6,6],[2,9,[6,0],[10,5],7],7,1],[[[]],7,9,[[8,8],[10,4,9]],9]]
[[1,3,[[6,7,2],7,[2,8]],[[5,5,0,2],[5,2]],10],[[6,0,8,[9,2],[]],9,[[9,0,5,7,2],8,4,5]]]
[[],[[[3,4,8,1],10,10,7,[7,4,7]],[0,9,2,[5],2],10],[],[3,1,[5,[1],[2]]],[[[7,1,4,5],10,6,1],[0,6,[3],[]],1,9,6]]
[[],[4,[[7,1,10,6,2],9,6,[9,6,9,4]],[1]],[]]
[[1,3],[[[8,10,3],[5],0]]]
[[[3,[3,3,10,6,2],2,[1]],[3,1,8,[3,8,2],3],[],10],[[],[[],[],[4],3,[2,7,3,2]],[4,3],8],[[[]],[7,9]]]
[[9,[[0,4,9],[5,1,10],6,0,[7,3]]]]
[[1,[7,3,0,[5,5,3,9,0],0],6],[7,1],[0,[4,[3],[6,2,5,8],[0,10]],[[5,4,4],[8],[10,3],[1,1,8,7],5],9],[]]
[[[[5]],[[1],4,[7,0,8,5],5,6],[1,[3,1],[0,9,6]]]]
[[[[5,2,9,1]],[[3,7,1,2,8],[1],[5,8,2]]],[],[[10,6,[0,5,9],2,[2,7,10]],0,[1,10,[10,10,10,0,4],[0,2,10,7],9]]]
[[[],[]],[[[8],[]],3],[],[[6,6,7]]]
[[9,[3,7,[]],8,2],[[9,8,9,3,8],[8,0,[1,9,6]],[2,[5,2],[1,7],3]],[]]
[[[4],[[7],[4,0]],[[1,1,0,9],[0,9,5],[4,6,7,5,9],0,[]],0,[10,[],6,3]],[3],[],[2,[[3,10],[]],[0,9,8,7],[],[2,4,[0,5,6,7]]],[[[9],[7,1,9],4],[[8,2],9]]]
[[8,[],4]]
[[],[[[4,8,9],3,9],[3,[7]],[[9],6,[5,2,10,10]],[[7,9,10],2,5]],[5,[]],[[],[5,[3,5,0,4],1,[2,8]],[[9,2,9,7,5],3,7]]]
[[[[10,4,2,0]]],[[[3,5,1],[3,4,10,5],2]]]
[[[4,[8],[6,4,3],6]],[[[10],2,[6,2],[5],2],1,[0,9,3,6],[[3,3,7]],[[10,10,10,3,7]]],[]]
[[6],[[5],8,5],[[8,[3,10,1],[],2,4],[8,[],[7,1,3,5]],[[1,9,4,7],6,[3,1],9]],[[[],1,9],1,[[1]]]]
[[],[1,4,5],[3],[[[4],6,[8,6,2,1,1],3,[1,1,7]],1]]
[[[],[1,[10],3,[8]],4,[]],[[[2,5,0],[9,5,7,10],4,[7,10],2]],[10],[5,[10,1],4,8],[[3],4,[],[]]]
[[[1,6]],[],[[8,9,6,[3,10,5,8,8]],1,8]]
[[7,4,[[],2],3,[]]]
[[5,1,4],[5,[5,10,7,[]]],[],[6],[]]
[[[9,0],[],[[3,5,6,1]]],[[[10,8,9,8],[4,8]],[3,[4,1,3,10],[7],[3]],[1,[0,7,1,0,2],[8,0,6,5,5],[8,2,10]]],[1]]
[[[4]],[7],[[4,5,[5,8,3,7,5]],6]]
[[[2,[1]],[3,[10,5,7,3],[],6,[8,0,2,8]]]]
[[8,[1,[]]],[],[7,6,[[8,10,1],[1,6,8,2,9],[0,2,0],4,[10,7,6,4,7]],[[0,3]]],[]]
[[0,3],[[3],1,[],[[7,4,8],8],[8,[3,2,9],[1,5],9]],[],[[],[5,9,[10],[8,3,7,5],9],[[6,10,5]],[7,[5,6]],[[5,7,9],1,[],[1]]]]
[[1,[0,4],[7,9,5,9]],[[9,8,3,[3,3,3,10],[3,4]]]]
[[6,[7,[2,8],0,2]],[[],6,2,6],[[],2,[[4]],2],[[10,6,2],2,8,[],[[],[4,9],5,10,[0,9]]]]
[[1,8,[4,[8,5,1,0],[4,2,9,0],[2,0,10]]]]
[[],[],[[2],[[],[7,10,0],2],[[6],3]],[8,10,[4]],[2,0,2,[2,[2,0],4,[1,2,7,4]],7]]
[[4,[[5,10,9,10,8],[0,9,0,8],4,1,10],[[0,3],[3,5],10]],[8],[],[7]]
[[[],[[2]]],[3]]
[[3,[],2],[[10,10,[3,1],7,6],5,10,[[1]],[8,[0,4,9,3],1,[5,5]]],[8,[[2,6,2],4,4,[9,5,3,3,4],[10,3,8,0,9]],2,[[0,8,4],[8,2],7,3]]]
[[9,9,5]]
[[6,1,[[10,10,4,3],5,[]],[8,0,[],[4,8,5,0,8]]],[2,[[]],[],9],[7]]
[[[[3,8,6,9,0],[0,10,3,7]],8],[],[[[],[],[1,10,7]],5]]
[[[5,4,[8,1,0,1],1],[0,10,10,9],3,[[]],3],[],[[[3,8,0,1],8],0],[7,[[]],[5,3,5],2],[[2],8,8,3]]
[[1]]
[[9,9,3,[4,5,7],4],[3,[],[[],2,[],3,7]],[],[[3,1],[10,7,6,[4,10,7],3],[],[10,[0,4,8]]]]
[[10],[7]]
[[[[],5,[0,2,1,8,8]],8,[7]]]
[[[[9],5],[5,9,[0,2,8],0],[[7],[4,10,7,5,0]],6,9],[[7],[7,0,[7,2,9]],[[0,0],10,[5]]]]
[[7,1,[8,9,[6,8],7,8],[3,2],2],[[5,[4,6,10,3,7],[5,6,10,7],3,[7,5,7,10,2]],[[4,5,10,6,10],[],7],[7,[9],[10,9,9]],4],[0,[5,3,[9,8]],[4,5,6,0,0],7],[2,1,[[2],[],[6,10],[8],[6,6,10,4,7]]]]

183
2022/14/README.md Normal file
View File

@ -0,0 +1,183 @@
\--- Day 14: Regolith Reservoir ---
----------
The distress signal leads you to a giant waterfall! Actually, hang on - the signal seems like it's coming from the waterfall itself, and that doesn't make any sense. However, you do notice a little path that leads *behind* the waterfall.
Correction: the distress signal leads you behind a giant waterfall! There seems to be a large cave system here, and the signal definitely leads further inside.
As you begin to make your way deeper underground, you feel the ground rumble for a moment. Sand begins pouring into the cave! If you don't quickly figure out where the sand is going, you could quickly become trapped!
Fortunately, your [familiarity](/2018/day/17) with analyzing the path of falling material will come in handy here. You scan a two-dimensional vertical slice of the cave above you (your puzzle input) and discover that it is mostly *air* with structures made of *rock*.
Your scan traces the path of each solid rock structure and reports the `x,y` coordinates that form the shape of the path, where `x` represents distance to the right and `y` represents distance down. Each path appears as a single line of text in your scan. After the first point of each path, each point indicates the end of a straight horizontal or vertical line to be drawn from the previous point. For example:
```
498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9
```
This scan means that there are two paths of rock; the first path consists of two straight lines, and the second path consists of three straight lines. (Specifically, the first path consists of a line of rock from `498,4` through `498,6` and another line of rock from `498,6` through `496,6`.)
The sand is pouring into the cave from point `500,0`.
Drawing rock as `#`, air as `.`, and the source of the sand as `+`, this becomes:
```
4 5 5
9 0 0
4 0 3
0 ......+...
1 ..........
2 ..........
3 ..........
4 ....#...##
5 ....#...#.
6 ..###...#.
7 ........#.
8 ........#.
9 #########.
```
Sand is produced *one unit at a time*, and the next unit of sand is not produced until the previous unit of sand *comes to rest*. A unit of sand is large enough to fill one tile of air in your scan.
A unit of sand always falls *down one step* if possible. If the tile immediately below is blocked (by rock or sand), the unit of sand attempts to instead move diagonally *one step down and to the left*. If that tile is blocked, the unit of sand attempts to instead move diagonally *one step down and to the right*. Sand keeps moving as long as it is able to do so, at each step trying to move down, then down-left, then down-right. If all three possible destinations are blocked, the unit of sand *comes to rest* and no longer moves, at which point the next unit of sand is created back at the source.
So, drawing sand that has come to rest as `o`, the first unit of sand simply falls straight down and then stops:
```
......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
........#.
......o.#.
#########.
```
The second unit of sand then falls straight down, lands on the first one, and then comes to rest to its left:
```
......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
........#.
.....oo.#.
#########.
```
After a total of five units of sand have come to rest, they form this pattern:
```
......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
......o.#.
....oooo#.
#########.
```
After a total of 22 units of sand:
```
......+...
..........
......o...
.....ooo..
....#ooo##
....#ooo#.
..###ooo#.
....oooo#.
...ooooo#.
#########.
```
Finally, only two more units of sand can possibly come to rest:
```
......+...
..........
......o...
.....ooo..
....#ooo##
...o#ooo#.
..###ooo#.
....oooo#.
.o.ooooo#.
#########.
```
Once all `*24*` units of sand shown above have come to rest, all further sand flows out the bottom, falling into the endless void. Just for fun, the path any new sand takes before falling forever is shown here with `~`:
```
.......+...
.......~...
......~o...
.....~ooo..
....~#ooo##
...~o#ooo#.
..~###ooo#.
..~..oooo#.
.~o.ooooo#.
~#########.
~..........
~..........
~..........
```
Using your scan, simulate the falling sand. *How many units of sand come to rest before sand starts flowing into the abyss below?*
\--- Part Two ---
----------
You realize you misread the scan. There isn't an endless void at the bottom of the scan - there's floor, and you're standing on it!
You don't have time to scan the floor, so assume the floor is an infinite horizontal line with a `y` coordinate equal to *two plus the highest `y` coordinate* of any point in your scan.
In the example above, the highest `y` coordinate of any point is `9`, and so the floor is at `y=11`. (This is as if your scan contained one extra rock path like `-infinity,11 -> infinity,11`.) With the added floor, the example above now looks like this:
```
...........+........
....................
....................
....................
.........#...##.....
.........#...#......
.......###...#......
.............#......
.............#......
.....#########......
....................
<-- etc #################### etc -->
```
To find somewhere safe to stand, you'll need to simulate falling sand until a unit of sand comes to rest at `500,0`, blocking the source entirely and stopping the flow of sand into the cave. In the example above, the situation finally looks like this after `*93*` units of sand come to rest:
```
............o............
...........ooo...........
..........ooooo..........
.........ooooooo.........
........oo#ooo##o........
.......ooo#ooo#ooo.......
......oo###ooo#oooo......
.....oooo.oooo#ooooo.....
....oooooooooo#oooooo....
...ooo#########ooooooo...
..ooooo.......ooooooooo..
#########################
```
Using your scan, simulate the falling sand until the source of the sand becomes blocked. *How many units of sand come to rest?*

164
2022/14/input.txt Normal file
View File

@ -0,0 +1,164 @@
514,127 -> 518,127
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
518,47 -> 525,47 -> 525,46
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
503,157 -> 507,157
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
517,129 -> 521,129
525,86 -> 529,86
522,84 -> 526,84
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
530,111 -> 535,111
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
520,131 -> 524,131
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
528,84 -> 532,84
511,129 -> 515,129
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
539,90 -> 539,91 -> 552,91 -> 552,90
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
508,127 -> 512,127
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
539,90 -> 539,91 -> 552,91 -> 552,90
511,125 -> 515,125
514,131 -> 518,131
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
526,109 -> 531,109
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
497,157 -> 501,157
539,90 -> 539,91 -> 552,91 -> 552,90
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
498,134 -> 498,135 -> 509,135 -> 509,134
503,151 -> 507,151
531,86 -> 535,86
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
498,134 -> 498,135 -> 509,135 -> 509,134
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
528,80 -> 532,80
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
540,109 -> 545,109
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
536,107 -> 541,107
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
534,84 -> 538,84
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
525,82 -> 529,82
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
520,114 -> 520,117 -> 514,117 -> 514,122 -> 533,122 -> 533,117 -> 525,117 -> 525,114
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
506,154 -> 510,154
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
519,86 -> 523,86
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
537,86 -> 541,86
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
508,131 -> 512,131
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
518,47 -> 525,47 -> 525,46
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
509,157 -> 513,157
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
533,109 -> 538,109
505,129 -> 509,129
518,76 -> 518,77 -> 529,77 -> 529,76
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
498,134 -> 498,135 -> 509,135 -> 509,134
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
537,94 -> 537,98 -> 536,98 -> 536,102 -> 542,102 -> 542,98 -> 539,98 -> 539,94
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
529,107 -> 534,107
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
532,105 -> 537,105
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
500,154 -> 504,154
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
523,111 -> 528,111
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
544,111 -> 549,111
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
518,76 -> 518,77 -> 529,77 -> 529,76
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
537,111 -> 542,111
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
523,73 -> 523,68 -> 523,73 -> 525,73 -> 525,72 -> 525,73 -> 527,73 -> 527,69 -> 527,73
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
518,76 -> 518,77 -> 529,77 -> 529,76
531,82 -> 535,82
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23
507,26 -> 507,28 -> 504,28 -> 504,33 -> 511,33 -> 511,28 -> 510,28 -> 510,26
511,36 -> 511,40 -> 503,40 -> 503,43 -> 519,43 -> 519,40 -> 515,40 -> 515,36
502,131 -> 506,131
508,60 -> 508,58 -> 508,60 -> 510,60 -> 510,55 -> 510,60 -> 512,60 -> 512,51 -> 512,60 -> 514,60 -> 514,59 -> 514,60 -> 516,60 -> 516,58 -> 516,60 -> 518,60 -> 518,50 -> 518,60 -> 520,60 -> 520,58 -> 520,60 -> 522,60 -> 522,52 -> 522,60 -> 524,60 -> 524,54 -> 524,60
488,148 -> 488,144 -> 488,148 -> 490,148 -> 490,141 -> 490,148 -> 492,148 -> 492,144 -> 492,148 -> 494,148 -> 494,145 -> 494,148 -> 496,148 -> 496,139 -> 496,148 -> 498,148 -> 498,145 -> 498,148 -> 500,148 -> 500,141 -> 500,148 -> 502,148 -> 502,143 -> 502,148 -> 504,148 -> 504,145 -> 504,148
490,23 -> 490,17 -> 490,23 -> 492,23 -> 492,22 -> 492,23 -> 494,23 -> 494,16 -> 494,23 -> 496,23 -> 496,17 -> 496,23 -> 498,23 -> 498,18 -> 498,23 -> 500,23 -> 500,13 -> 500,23 -> 502,23 -> 502,13 -> 502,23 -> 504,23 -> 504,13 -> 504,23 -> 506,23 -> 506,15 -> 506,23 -> 508,23 -> 508,22 -> 508,23

View File

@ -1,4 +1,4 @@
# solved but WIP!!!
from aocd import submit
# from pysnooper import snoop

2
2022/14/test.txt Normal file
View File

@ -0,0 +1,2 @@
498,4 -> 498,6 -> 496,6
503,4 -> 502,4 -> 502,9 -> 494,9

134
2022/15/puzzle.md Normal file
View File

@ -0,0 +1,134 @@
\--- Day 15: Beacon Exclusion Zone ---
----------
You feel the ground rumble again as the distress signal leads you to a large network of subterranean tunnels. You don't have time to search them all, but you don't need to: your pack contains a set of deployable *sensors* that you imagine were originally built to locate lost Elves.
The sensors aren't very powerful, but that's okay; your handheld device indicates that you're close enough to the source of the distress signal to use them. You pull the emergency sensor system out of your pack, hit the big button on top, and the sensors zoom off down the tunnels.
Once a sensor finds a spot it thinks will give it a good reading, it attaches itself to a hard surface and begins monitoring for the nearest signal source *beacon*. Sensors and beacons always exist at integer coordinates. Each sensor knows its own position and can *determine the position of a beacon precisely*; however, sensors can only lock on to the one beacon *closest to the sensor* as measured by the [Manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry). (There is never a tie where two beacons are the same distance to a sensor.)
It doesn't take long for the sensors to report back their positions and closest beacons (your puzzle input). For example:
```
Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3
```
So, consider the sensor at `2,18`; the closest beacon to it is at `-2,15`. For the sensor at `9,16`, the closest beacon to it is at `10,16`.
Drawing sensors as `S` and beacons as `B`, the above arrangement of sensors and beacons looks like this:
```
1 1 2 2
0 5 0 5 0 5
0 ....S.......................
1 ......................S.....
2 ...............S............
3 ................SB..........
4 ............................
5 ............................
6 ............................
7 ..........S.......S.........
8 ............................
9 ............................
10 ....B.......................
11 ..S.........................
12 ............................
13 ............................
14 ..............S.......S.....
15 B...........................
16 ...........SB...............
17 ................S..........B
18 ....S.......................
19 ............................
20 ............S......S........
21 ............................
22 .......................B....
```
This isn't necessarily a comprehensive map of all beacons in the area, though. Because each sensor only identifies its closest beacon, if a sensor detects a beacon, you know there are no other beacons that close or closer to that sensor. There could still be beacons that just happen to not be the closest beacon to any sensor. Consider the sensor at `8,7`:
```
1 1 2 2
0 5 0 5 0 5
-2 ..........#.................
-1 .........###................
0 ....S...#####...............
1 .......#######........S.....
2 ......#########S............
3 .....###########SB..........
4 ....#############...........
5 ...###############..........
6 ..#################.........
7 .#########S#######S#........
8 ..#################.........
9 ...###############..........
10 ....B############...........
11 ..S..###########............
12 ......#########.............
13 .......#######..............
14 ........#####.S.......S.....
15 B........###................
16 ..........#SB...............
17 ................S..........B
18 ....S.......................
19 ............................
20 ............S......S........
21 ............................
22 .......................B....
```
This sensor's closest beacon is at `2,10`, and so you know there are no beacons that close or closer (in any positions marked `#`).
None of the detected beacons seem to be producing the distress signal, so you'll need to work out where the distress beacon is by working out where it *isn't*. For now, keep things simple by counting the positions where a beacon cannot possibly be along just a single row.
So, suppose you have an arrangement of beacons and sensors like in the example above and, just in the row where `y=10`, you'd like to count the number of positions a beacon cannot possibly exist. The coverage from all sensors near that row looks like this:
```
1 1 2 2
0 5 0 5 0 5
9 ...#########################...
10 ..####B######################..
11 .###S#############.###########.
```
In this example, in the row where `y=10`, there are `*26*` positions where a beacon cannot be present.
Consult the report from the sensors you just deployed. *In the row where `y=2000000`, how many positions cannot contain a beacon?*
Your puzzle answer was `4724228`.
The first half of this puzzle is complete! It provides one gold star: \*
\--- Part Two ---
----------
Your handheld device indicates that the distress signal is coming from a beacon nearby. The distress beacon is not detected by any sensor, but the distress beacon must have `x` and `y` coordinates each no lower than `0` and no larger than `4000000`.
To isolate the distress beacon's signal, you need to determine its *tuning frequency*, which can be found by multiplying its `x` coordinate by `4000000` and then adding its `y` coordinate.
In the example above, the search space is smaller: instead, the `x` and `y` coordinates can each be at most `20`. With this reduced search area, there is only a single position that could have a beacon: `x=14, y=11`. The tuning frequency for this distress beacon is `*56000011*`.
Find the only possible position for the distress beacon. *What is its tuning frequency?*
Answer:
Although it hasn't changed, you can still [get your puzzle input](15/input).
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Beacon+Exclusion+Zone%22+%2D+Day+15+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F15&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

159
2022/16/puzzle.md Normal file
View File

@ -0,0 +1,159 @@
\--- Day 16: Proboscidea Volcanium ---
----------
The sensors have led you to the origin of the distress signal: yet another handheld device, just like the one the Elves gave you. However, you don't see any Elves around; instead, the device is surrounded by elephants! They must have gotten lost in these tunnels, and one of the elephants apparently figured out how to turn on the distress signal.
The ground rumbles again, much stronger this time. What kind of cave is this, exactly? You scan the cave with your handheld device; it reports mostly igneous rock, some ash, pockets of pressurized gas, magma... this isn't just a cave, it's a volcano!
You need to get the elephants out of here, quickly. Your device estimates that you have *30 minutes* before the volcano erupts, so you don't have time to go back out the way you came in.
You scan the cave for other options and discover a network of pipes and pressure-release *valves*. You aren't sure how such a system got into a volcano, but you don't have time to complain; your device produces a report (your puzzle input) of each valve's *flow rate* if it were opened (in pressure per minute) and the tunnels you could use to move between the valves.
There's even a valve in the room you and the elephants are currently standing in labeled `AA`. You estimate it will take you one minute to open a single valve and one minute to follow any tunnel from one valve to another. What is the most pressure you could release?
For example, suppose you had the following scan output:
```
Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II
```
All of the valves begin *closed*. You start at valve `AA`, but it must be damaged or jammed or something: its flow rate is `0`, so there's no point in opening it. However, you could spend one minute moving to valve `BB` and another minute opening it; doing so would release pressure during the remaining *28 minutes* at a flow rate of `13`, a total eventual pressure release of `28 * 13 = *364*`. Then, you could spend your third minute moving to valve `CC` and your fourth minute opening it, providing an additional *26 minutes* of eventual pressure release at a flow rate of `2`, or `*52*` total pressure released by valve `CC`.
Making your way through the tunnels like this, you could probably open many or all of the valves by the time 30 minutes have elapsed. However, you need to release as much pressure as possible, so you'll need to be methodical. Instead, consider this approach:
```
== Minute 1 ==
No valves are open.
You move to valve DD.
== Minute 2 ==
No valves are open.
You open valve DD.
== Minute 3 ==
Valve DD is open, releasing 20 pressure.
You move to valve CC.
== Minute 4 ==
Valve DD is open, releasing 20 pressure.
You move to valve BB.
== Minute 5 ==
Valve DD is open, releasing 20 pressure.
You open valve BB.
== Minute 6 ==
Valves BB and DD are open, releasing 33 pressure.
You move to valve AA.
== Minute 7 ==
Valves BB and DD are open, releasing 33 pressure.
You move to valve II.
== Minute 8 ==
Valves BB and DD are open, releasing 33 pressure.
You move to valve JJ.
== Minute 9 ==
Valves BB and DD are open, releasing 33 pressure.
You open valve JJ.
== Minute 10 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve II.
== Minute 11 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve AA.
== Minute 12 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve DD.
== Minute 13 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve EE.
== Minute 14 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve FF.
== Minute 15 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve GG.
== Minute 16 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You move to valve HH.
== Minute 17 ==
Valves BB, DD, and JJ are open, releasing 54 pressure.
You open valve HH.
== Minute 18 ==
Valves BB, DD, HH, and JJ are open, releasing 76 pressure.
You move to valve GG.
== Minute 19 ==
Valves BB, DD, HH, and JJ are open, releasing 76 pressure.
You move to valve FF.
== Minute 20 ==
Valves BB, DD, HH, and JJ are open, releasing 76 pressure.
You move to valve EE.
== Minute 21 ==
Valves BB, DD, HH, and JJ are open, releasing 76 pressure.
You open valve EE.
== Minute 22 ==
Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure.
You move to valve DD.
== Minute 23 ==
Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure.
You move to valve CC.
== Minute 24 ==
Valves BB, DD, EE, HH, and JJ are open, releasing 79 pressure.
You open valve CC.
== Minute 25 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
== Minute 26 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
== Minute 27 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
== Minute 28 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
== Minute 29 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
== Minute 30 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing 81 pressure.
```
This approach lets you release the most pressure possible in 30 minutes with this valve layout, `*1651*`.
Work out the steps to release the most pressure in 30 minutes. *What is the most pressure you can release?*
To begin, [get your puzzle input](16/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Proboscidea+Volcanium%22+%2D+Day+16+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F16&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

356
2022/17/puzzle.md Normal file
View File

@ -0,0 +1,356 @@
\--- Day 17: Pyroclastic Flow ---
----------
Your handheld device has located an alternative exit from the cave for you and the elephants. The ground is rumbling almost continuously now, but the strange valves bought you some time. It's definitely getting warmer in here, though.
The tunnels eventually open into a very tall, narrow chamber. Large, oddly-shaped rocks are falling into the chamber from above, presumably due to all the rumbling. If you can't work out where the rocks will fall next, you might be crushed!
The five types of rocks have the following peculiar shapes, where `#` is rock and `.` is empty space:
```
####
.#.
###
.#.
..#
..#
###
#
#
#
#
##
##
```
The rocks fall in the order shown above: first the `-` shape, then the `+` shape, and so on. Once the end of the list is reached, the same order repeats: the `-` shape falls first, sixth, 11th, 16th, etc.
The rocks don't spin, but they do get pushed around by jets of hot gas coming out of the walls themselves. A quick scan reveals the effect the jets of hot gas will have on the rocks as they fall (your puzzle input).
For example, suppose this was the jet pattern in your cave:
```
>>><<><>><<<>><>>><<<>>><<<><<<>><>><<>>
```
In jet patterns, `<` means a push to the left, while `>` means a push to the right. The pattern above means that the jets will push a falling rock right, then right, then right, then left, then left, then right, and so on. If the end of the list is reached, it repeats.
The tall, vertical chamber is exactly *seven units wide*. Each rock appears so that its left edge is two units away from the left wall and its bottom edge is three units above the highest rock in the room (or the floor, if there isn't one).
After a rock appears, it alternates between *being pushed by a jet of hot gas* one unit (in the direction indicated by the next symbol in the jet pattern) and then *falling one unit down*. If any movement would cause any part of the rock to move into the walls, floor, or a stopped rock, the movement instead does not occur. If a *downward* movement would have caused a falling rock to move into the floor or an already-fallen rock, the falling rock stops where it is (having landed on something) and a new rock immediately begins falling.
Drawing falling rocks with `@` and stopped rocks with `#`, the jet pattern in the example above manifests as follows:
```
The first rock begins falling:
|..@@@@.|
|.......|
|.......|
|.......|
+-------+
Jet of gas pushes rock right:
|...@@@@|
|.......|
|.......|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
|.......|
|.......|
+-------+
Jet of gas pushes rock right, but nothing happens:
|...@@@@|
|.......|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
|.......|
+-------+
Jet of gas pushes rock right, but nothing happens:
|...@@@@|
|.......|
+-------+
Rock falls 1 unit:
|...@@@@|
+-------+
Jet of gas pushes rock left:
|..@@@@.|
+-------+
Rock falls 1 unit, causing it to come to rest:
|..####.|
+-------+
A new rock begins falling:
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|.......|
|..####.|
+-------+
Jet of gas pushes rock left:
|..@....|
|.@@@...|
|..@....|
|.......|
|.......|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|..@....|
|.@@@...|
|..@....|
|.......|
|.......|
|..####.|
+-------+
Jet of gas pushes rock right:
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|...@...|
|..@@@..|
|...@...|
|.......|
|..####.|
+-------+
Jet of gas pushes rock left:
|..@....|
|.@@@...|
|..@....|
|.......|
|..####.|
+-------+
Rock falls 1 unit:
|..@....|
|.@@@...|
|..@....|
|..####.|
+-------+
Jet of gas pushes rock right:
|...@...|
|..@@@..|
|...@...|
|..####.|
+-------+
Rock falls 1 unit, causing it to come to rest:
|...#...|
|..###..|
|...#...|
|..####.|
+-------+
A new rock begins falling:
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|...#...|
|..###..|
|...#...|
|..####.|
+-------+
```
The moment each of the next few rocks begins falling, you would see this:
```
|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|..#....|
|..#....|
|####...|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|.......|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|..#....|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|.....#.|
|.....#.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|....##.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|##..##.|
|######.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
```
To prove to the elephants your simulation is accurate, they want to know how tall the tower will get after 2022 rocks have stopped (but before the 2023rd rock begins falling). In this example, the tower of rocks will be `*3068*` units tall.
*How many units tall will the tower of rocks be after 2022 rocks have stopped falling?*
To begin, [get your puzzle input](17/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Pyroclastic+Flow%22+%2D+Day+17+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

182
2022/19/puzzle.md Normal file
View File

@ -0,0 +1,182 @@
\--- Day 19: Not Enough Minerals ---
----------
Your scans show that the lava did indeed form obsidian!
The wind has changed direction enough to stop sending lava droplets toward you, so you and the elephants exit the cave. As you do, you notice a collection of [geodes](https://en.wikipedia.org/wiki/Geode) around the pond. Perhaps you could use the obsidian to create some *geode-cracking robots* and break them open?
To collect the obsidian from the bottom of the pond, you'll need waterproof *obsidian-collecting robots*. Fortunately, there is an abundant amount of clay nearby that you can use to make them waterproof.
In order to harvest the clay, you'll need special-purpose *clay-collecting robots*. To make any type of robot, you'll need *ore*, which is also plentiful but in the opposite direction from the clay.
Collecting ore requires *ore-collecting robots* with big drills. Fortunately, *you have exactly one ore-collecting robot* in your pack that you can use to kickstart the whole operation.
Each robot can collect 1 of its resource type per minute. It also takes one minute for the robot factory (also conveniently from your pack) to construct any type of robot, although it consumes the necessary resources available when construction begins.
The robot factory has many *blueprints* (your puzzle input) you can choose from, but once you've configured it with a blueprint, you can't change it. You'll need to work out which blueprint is best.
For example:
```
Blueprint 1:
Each ore robot costs 4 ore.
Each clay robot costs 2 ore.
Each obsidian robot costs 3 ore and 14 clay.
Each geode robot costs 2 ore and 7 obsidian.
Blueprint 2:
Each ore robot costs 2 ore.
Each clay robot costs 3 ore.
Each obsidian robot costs 3 ore and 8 clay.
Each geode robot costs 3 ore and 12 obsidian.
```
(Blueprints have been line-wrapped here for legibility. The robot factory's actual assortment of blueprints are provided one blueprint per line.)
The elephants are starting to look hungry, so you shouldn't take too long; you need to figure out which blueprint would maximize the number of opened geodes after *24 minutes* by figuring out which robots to build and when to build them.
Using blueprint 1 in the example above, the largest number of geodes you could open in 24 minutes is `*9*`. One way to achieve that is:
```
== Minute 1 ==
1 ore-collecting robot collects 1 ore; you now have 1 ore.
== Minute 2 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
== Minute 3 ==
Spend 2 ore to start building a clay-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 1 ore.
The new clay-collecting robot is ready; you now have 1 of them.
== Minute 4 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
1 clay-collecting robot collects 1 clay; you now have 1 clay.
== Minute 5 ==
Spend 2 ore to start building a clay-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 1 ore.
1 clay-collecting robot collects 1 clay; you now have 2 clay.
The new clay-collecting robot is ready; you now have 2 of them.
== Minute 6 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
2 clay-collecting robots collect 2 clay; you now have 4 clay.
== Minute 7 ==
Spend 2 ore to start building a clay-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 1 ore.
2 clay-collecting robots collect 2 clay; you now have 6 clay.
The new clay-collecting robot is ready; you now have 3 of them.
== Minute 8 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
3 clay-collecting robots collect 3 clay; you now have 9 clay.
== Minute 9 ==
1 ore-collecting robot collects 1 ore; you now have 3 ore.
3 clay-collecting robots collect 3 clay; you now have 12 clay.
== Minute 10 ==
1 ore-collecting robot collects 1 ore; you now have 4 ore.
3 clay-collecting robots collect 3 clay; you now have 15 clay.
== Minute 11 ==
Spend 3 ore and 14 clay to start building an obsidian-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 2 ore.
3 clay-collecting robots collect 3 clay; you now have 4 clay.
The new obsidian-collecting robot is ready; you now have 1 of them.
== Minute 12 ==
Spend 2 ore to start building a clay-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 1 ore.
3 clay-collecting robots collect 3 clay; you now have 7 clay.
1 obsidian-collecting robot collects 1 obsidian; you now have 1 obsidian.
The new clay-collecting robot is ready; you now have 4 of them.
== Minute 13 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
4 clay-collecting robots collect 4 clay; you now have 11 clay.
1 obsidian-collecting robot collects 1 obsidian; you now have 2 obsidian.
== Minute 14 ==
1 ore-collecting robot collects 1 ore; you now have 3 ore.
4 clay-collecting robots collect 4 clay; you now have 15 clay.
1 obsidian-collecting robot collects 1 obsidian; you now have 3 obsidian.
== Minute 15 ==
Spend 3 ore and 14 clay to start building an obsidian-collecting robot.
1 ore-collecting robot collects 1 ore; you now have 1 ore.
4 clay-collecting robots collect 4 clay; you now have 5 clay.
1 obsidian-collecting robot collects 1 obsidian; you now have 4 obsidian.
The new obsidian-collecting robot is ready; you now have 2 of them.
== Minute 16 ==
1 ore-collecting robot collects 1 ore; you now have 2 ore.
4 clay-collecting robots collect 4 clay; you now have 9 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 6 obsidian.
== Minute 17 ==
1 ore-collecting robot collects 1 ore; you now have 3 ore.
4 clay-collecting robots collect 4 clay; you now have 13 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 8 obsidian.
== Minute 18 ==
Spend 2 ore and 7 obsidian to start building a geode-cracking robot.
1 ore-collecting robot collects 1 ore; you now have 2 ore.
4 clay-collecting robots collect 4 clay; you now have 17 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 3 obsidian.
The new geode-cracking robot is ready; you now have 1 of them.
== Minute 19 ==
1 ore-collecting robot collects 1 ore; you now have 3 ore.
4 clay-collecting robots collect 4 clay; you now have 21 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 5 obsidian.
1 geode-cracking robot cracks 1 geode; you now have 1 open geode.
== Minute 20 ==
1 ore-collecting robot collects 1 ore; you now have 4 ore.
4 clay-collecting robots collect 4 clay; you now have 25 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 7 obsidian.
1 geode-cracking robot cracks 1 geode; you now have 2 open geodes.
== Minute 21 ==
Spend 2 ore and 7 obsidian to start building a geode-cracking robot.
1 ore-collecting robot collects 1 ore; you now have 3 ore.
4 clay-collecting robots collect 4 clay; you now have 29 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 2 obsidian.
1 geode-cracking robot cracks 1 geode; you now have 3 open geodes.
The new geode-cracking robot is ready; you now have 2 of them.
== Minute 22 ==
1 ore-collecting robot collects 1 ore; you now have 4 ore.
4 clay-collecting robots collect 4 clay; you now have 33 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 4 obsidian.
2 geode-cracking robots crack 2 geodes; you now have 5 open geodes.
== Minute 23 ==
1 ore-collecting robot collects 1 ore; you now have 5 ore.
4 clay-collecting robots collect 4 clay; you now have 37 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 6 obsidian.
2 geode-cracking robots crack 2 geodes; you now have 7 open geodes.
== Minute 24 ==
1 ore-collecting robot collects 1 ore; you now have 6 ore.
4 clay-collecting robots collect 4 clay; you now have 41 clay.
2 obsidian-collecting robots collect 2 obsidian; you now have 8 obsidian.
2 geode-cracking robots crack 2 geodes; you now have 9 open geodes.
```
However, by using blueprint 2 in the example above, you could do even better: the largest number of geodes you could open in 24 minutes is `*12*`.
Determine the *quality level* of each blueprint by *multiplying that blueprint's ID number* with the largest number of geodes that can be opened in 24 minutes using that blueprint. In this example, the first blueprint has ID 1 and can open 9 geodes, so its quality level is `*9*`. The second blueprint has ID 2 and can open 12 geodes, so its quality level is `*24*`. Finally, if you *add up the quality levels* of all of the blueprints in the list, you get `*33*`.
Determine the quality level of each blueprint using the largest number of geodes it could produce in 24 minutes. *What do you get if you add up the quality level of all of the blueprints in your list?*
To begin, [get your puzzle input](19/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Not+Enough+Minerals%22+%2D+Day+19+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F19&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

70
2022/20/puzzle.md Normal file
View File

@ -0,0 +1,70 @@
\--- Day 20: Grove Positioning System ---
----------
It's finally time to meet back up with the Elves. When you try to contact them, however, you get no reply. Perhaps you're out of range?
You know they're headed to the grove where the *star* fruit grows, so if you can figure out where that is, you should be able to meet back up with them.
Fortunately, your handheld device has a file (your puzzle input) that contains the grove's coordinates! Unfortunately, the file is *encrypted* - just in case the device were to fall into the wrong hands.
Maybe you can decrypt it?
When you were still back at the camp, you overheard some Elves talking about coordinate file encryption. The main operation involved in decrypting the file is called *mixing*.
The encrypted file is a list of numbers. To *mix* the file, move each number forward or backward in the file a number of positions equal to the value of the number being moved. The list is *circular*, so moving a number off one end of the list wraps back around to the other end as if the ends were connected.
For example, to move the `1` in a sequence like `4, 5, 6, *1*, 7, 8, 9`, the `1` moves one position forward: `4, 5, 6, 7, *1*, 8, 9`. To move the `-2` in a sequence like `4, *-2*, 5, 6, 7, 8, 9`, the `-2` moves two positions backward, wrapping around: `4, 5, 6, 7, 8, *-2*, 9`.
The numbers should be moved *in the order they originally appear* in the encrypted file. Numbers moving around during the mixing process do not change the order in which the numbers are moved.
Consider this encrypted file:
```
1
2
-3
3
-2
0
4
```
Mixing this file proceeds as follows:
```
Initial arrangement:
1, 2, -3, 3, -2, 0, 4
1 moves between 2 and -3:
2, 1, -3, 3, -2, 0, 4
2 moves between -3 and 3:
1, -3, 2, 3, -2, 0, 4
-3 moves between -2 and 0:
1, 2, 3, -2, -3, 0, 4
3 moves between 0 and 4:
1, 2, -2, -3, 0, 3, 4
-2 moves between 4 and 1:
1, 2, -3, 0, 3, 4, -2
0 does not move:
1, 2, -3, 0, 3, 4, -2
4 moves between -3 and 0:
1, 2, -3, 4, 0, 3, -2
```
Then, the grove coordinates can be found by looking at the 1000th, 2000th, and 3000th numbers after the value `0`, wrapping around the list as necessary. In the above example, the 1000th number after `0` is `*4*`, the 2000th is `*-3*`, and the 3000th is `*2*`; adding these together produces `*3*`.
Mix your encrypted file exactly once. *What is the sum of the three numbers that form the grove coordinates?*
To begin, [get your puzzle input](20/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Grove+Positioning+System%22+%2D+Day+20+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F20&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

53
2022/21/puzzle.md Normal file
View File

@ -0,0 +1,53 @@
\--- Day 21: Monkey Math ---
----------
The [monkeys](11) are back! You're worried they're going to try to steal your stuff again, but it seems like they're just holding their ground and making various monkey noises at you.
Eventually, one of the elephants realizes you don't speak monkey and comes over to interpret. As it turns out, they overheard you talking about trying to find the grove; they can show you a shortcut if you answer their *riddle*.
Each monkey is given a *job*: either to *yell a specific number* or to *yell the result of a math operation*. All of the number-yelling monkeys know their number from the start; however, the math operation monkeys need to wait for two other monkeys to yell a number, and those two other monkeys might *also* be waiting on other monkeys.
Your job is to *work out the number the monkey named `root` will yell* before the monkeys figure it out themselves.
For example:
```
root: pppw + sjmn
dbpl: 5
cczh: sllz + lgvd
zczc: 2
ptdq: humn - dvpt
dvpt: 3
lfqf: 4
humn: 5
ljgn: 2
sjmn: drzm * dbpl
sllz: 4
pppw: cczh / lfqf
lgvd: ljgn * ptdq
drzm: hmdt - zczc
hmdt: 32
```
Each line contains the name of a monkey, a colon, and then the job of that monkey:
* A lone number means the monkey's job is simply to yell that number.
* A job like `aaaa + bbbb` means the monkey waits for monkeys `aaaa` and `bbbb` to yell each of their numbers; the monkey then yells the sum of those two numbers.
* `aaaa - bbbb` means the monkey yells `aaaa`'s number minus `bbbb`'s number.
* Job `aaaa * bbbb` will yell `aaaa`'s number multiplied by `bbbb`'s number.
* Job `aaaa / bbbb` will yell `aaaa`'s number divided by `bbbb`'s number.
So, in the above example, monkey `drzm` has to wait for monkeys `hmdt` and `zczc` to yell their numbers. Fortunately, both `hmdt` and `zczc` have jobs that involve simply yelling a single number, so they do this immediately: `32` and `2`. Monkey `drzm` can then yell its number by finding `32` minus `2`: `*30*`.
Then, monkey `sjmn` has one of its numbers (`30`, from monkey `drzm`), and already has its other number, `5`, from `dbpl`. This allows it to yell its own number by finding `30` multiplied by `5`: `*150*`.
This process continues until `root` yells a number: `*152*`.
However, your actual situation involves considerably more monkeys. *What number will the monkey named `root` yell?*
To begin, [get your puzzle input](21/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Monkey+Math%22+%2D+Day+21+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F21&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

93
2022/22/puzzle.md Normal file
View File

@ -0,0 +1,93 @@
\--- Day 22: Monkey Map ---
----------
The monkeys take you on a surprisingly easy trail through the jungle. They're even going in roughly the right direction according to your handheld device's Grove Positioning System.
As you walk, the monkeys explain that the grove is protected by a *force field*. To pass through the force field, you have to enter a password; doing so involves tracing a specific *path* on a strangely-shaped board.
At least, you're pretty sure that's what you have to do; the elephants aren't exactly fluent in monkey.
The monkeys give you notes that they took when they last saw the password entered (your puzzle input).
For example:
```
...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5
```
The first half of the monkeys' notes is a *map of the board*. It is comprised of a set of *open tiles* (on which you can move, drawn `.`) and *solid walls* (tiles which you cannot enter, drawn `#`).
The second half is a description of *the path you must follow*. It consists of alternating numbers and letters:
* A *number* indicates the *number of tiles to move* in the direction you are facing. If you run into a wall, you stop moving forward and continue with the next instruction.
* A *letter* indicates whether to turn 90 degrees *clockwise* (`R`) or *counterclockwise* (`L`). Turning happens in-place; it does not change your current tile.
So, a path like `10R5` means "go forward 10 tiles, then turn clockwise 90 degrees, then go forward 5 tiles".
You begin the path in the leftmost open tile of the top row of tiles. Initially, you are facing *to the right* (from the perspective of how the map is drawn).
If a movement instruction would take you off of the map, you *wrap around* to the other side of the board. In other words, if your next tile is off of the board, you should instead look in the direction opposite of your current facing as far as you can until you find the opposite edge of the board, then reappear there.
For example, if you are at `A` and facing to the right, the tile in front of you is marked `B`; if you are at `C` and facing down, the tile in front of you is marked `D`:
```
...#
.#..
#...
....
...#.D.....#
........#...
B.#....#...A
.....C....#.
...#....
.....#..
.#......
......#.
```
It is possible for the next tile (after wrapping around) to be a *wall*; this still counts as there being a wall in front of you, and so movement stops before you actually wrap to the other side of the board.
By drawing the *last facing you had* with an arrow on each tile you visit, the full path taken by the above example looks like this:
```
>>v#
.#v.
#.v.
..v.
...#...v..v#
>>>v...>#.>>
..#v...#....
...>>>>v..#.
...#....
.....#..
.#......
......#.
```
To finish providing the password to this strange input device, you need to determine numbers for your final *row*, *column*, and *facing* as your final position appears from the perspective of the original map. Rows start from `1` at the top and count downward; columns start from `1` at the left and count rightward. (In the above example, row 1, column 1 refers to the empty space with no tile on it in the top-left corner.) Facing is `0` for right (`>`), `1` for down (`v`), `2` for left (`<`), and `3` for up (`^`). The *final password* is the sum of 1000 times the row, 4 times the column, and the facing.
In the above example, the final row is `6`, the final column is `8`, and the final facing is `0`. So, the final password is 1000 \* 6 + 4 \* 8 + 0: `*6032*`.
Follow the path given in the monkeys' notes. *What is the final password?*
To begin, [get your puzzle input](22/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Monkey+Map%22+%2D+Day+22+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F22&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

235
2022/23/puzzle.md Normal file
View File

@ -0,0 +1,235 @@
\--- Day 23: Unstable Diffusion ---
----------
You enter a large crater of gray dirt where the grove is supposed to be. All around you, plants you imagine were expected to be full of fruit are instead withered and broken. A large group of Elves has formed in the middle of the grove.
"...but this volcano has been dormant for months. Without ash, the fruit can't grow!"
You look up to see a massive, snow-capped mountain towering above you.
"It's not like there are other active volcanoes here; we've looked everywhere."
"But our scanners show active magma flows; clearly it's going *somewhere*."
They finally notice you at the edge of the grove, your pack almost overflowing from the random *star* fruit you've been collecting. Behind you, elephants and monkeys explore the grove, looking concerned. Then, the Elves recognize the ash cloud slowly spreading above your recent detour.
"Why do you--" "How is--" "Did you just--"
Before any of them can form a complete question, another Elf speaks up: "Okay, new plan. We have almost enough fruit already, and ash from the plume should spread here eventually. If we quickly plant new seedlings now, we can still make it to the extraction point. Spread out!"
The Elves each reach into their pack and pull out a tiny plant. The plants rely on important nutrients from the ash, so they can't be planted too close together.
There isn't enough time to let the Elves figure out where to plant the seedlings themselves; you quickly scan the grove (your puzzle input) and note their positions.
For example:
```
....#..
..###.#
#...#.#
.#...##
#.###..
##.#.##
.#..#..
```
The scan shows Elves `#` and empty ground `.`; outside your scan, more empty ground extends a long way in every direction. The scan is oriented so that *north is up*; orthogonal directions are written N (north), S (south), W (west), and E (east), while diagonal directions are written NE, NW, SE, SW.
The Elves follow a time-consuming process to figure out where they should each go; you can speed up this process considerably. The process consists of some number of *rounds* during which Elves alternate between considering where to move and actually moving.
During the *first half* of each round, each Elf considers the eight positions adjacent to themself. If no other Elves are in one of those eight positions, the Elf *does not do anything* during this round. Otherwise, the Elf looks in each of four directions in the following order and *proposes* moving one step in the *first valid direction*:
* If there is no Elf in the N, NE, or NW adjacent positions, the Elf proposes moving *north* one step.
* If there is no Elf in the S, SE, or SW adjacent positions, the Elf proposes moving *south* one step.
* If there is no Elf in the W, NW, or SW adjacent positions, the Elf proposes moving *west* one step.
* If there is no Elf in the E, NE, or SE adjacent positions, the Elf proposes moving *east* one step.
After each Elf has had a chance to propose a move, the *second half* of the round can begin. Simultaneously, each Elf moves to their proposed destination tile if they were the *only* Elf to propose moving to that position. If two or more Elves propose moving to the same position, *none* of those Elves move.
Finally, at the end of the round, the *first direction* the Elves considered is moved to the end of the list of directions. For example, during the second round, the Elves would try proposing a move to the south first, then west, then east, then north. On the third round, the Elves would first consider west, then east, then north, then south.
As a smaller example, consider just these five Elves:
```
.....
..##.
..#..
.....
..##.
.....
```
The northernmost two Elves and southernmost two Elves all propose moving north, while the middle Elf cannot move north and proposes moving south. The middle Elf proposes the same destination as the southwest Elf, so neither of them move, but the other three do:
```
..##.
.....
..#..
...#.
..#..
.....
```
Next, the northernmost two Elves and the southernmost Elf all propose moving south. Of the remaining middle two Elves, the west one cannot move south and proposes moving west, while the east one cannot move south *or* west and proposes moving east. All five Elves succeed in moving to their proposed positions:
```
.....
..##.
.#...
....#
.....
..#..
```
Finally, the southernmost two Elves choose not to move at all. Of the remaining three Elves, the west one proposes moving west, the east one proposes moving east, and the middle one proposes moving north; all three succeed in moving:
```
..#..
....#
#....
....#
.....
..#..
```
At this point, no Elves need to move, and so the process ends.
The larger example above proceeds as follows:
```
== Initial State ==
..............
..............
.......#......
.....###.#....
...#...#.#....
....#...##....
...#.###......
...##.#.##....
....#..#......
..............
..............
..............
== End of Round 1 ==
..............
.......#......
.....#...#....
...#..#.#.....
.......#..#...
....#.#.##....
..#..#.#......
..#.#.#.##....
..............
....#..#......
..............
..............
== End of Round 2 ==
..............
.......#......
....#.....#...
...#..#.#.....
.......#...#..
...#..#.#.....
.#...#.#.#....
..............
..#.#.#.##....
....#..#......
..............
..............
== End of Round 3 ==
..............
.......#......
.....#....#...
..#..#...#....
.......#...#..
...#..#.#.....
.#..#.....#...
.......##.....
..##.#....#...
...#..........
.......#......
..............
== End of Round 4 ==
..............
.......#......
......#....#..
..#...##......
...#.....#.#..
.........#....
.#...###..#...
..#......#....
....##....#...
....#.........
.......#......
..............
== End of Round 5 ==
.......#......
..............
..#..#.....#..
.........#....
......##...#..
.#.#.####.....
...........#..
....##..#.....
..#...........
..........#...
....#..#......
..............
```
After a few more rounds...
```
== End of Round 10 ==
.......#......
...........#..
..#.#..#......
......#.......
...#.....#..#.
.#......##....
.....##.......
..#........#..
....#.#..#....
..............
....#..#..#...
..............
```
To make sure they're on the right track, the Elves like to check after round 10 that they're making good progress toward covering enough ground. To do this, count the number of empty ground tiles contained by the smallest rectangle that contains every Elf. (The edges of the rectangle should be aligned to the N/S/E/W directions; the Elves do not have the patience to calculate arbitrary rectangles.) In the above example, that rectangle is:
```
......#.....
..........#.
.#.#..#.....
.....#......
..#.....#..#
#......##...
....##......
.#........#.
...#.#..#...
............
...#..#..#..
```
In this region, the number of empty ground tiles is `*110*`.
Simulate the Elves' process and find the smallest rectangle that contains the Elves after 10 rounds. *How many empty ground tiles does that rectangle contain?*
To begin, [get your puzzle input](23/input).
Answer:
You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22Unstable+Diffusion%22+%2D+Day+23+%2D+Advent+of+Code+2022&url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F23&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.

515
bin/new
View File

@ -1,31 +1,117 @@
#!/usr/bin/env bash
#
# for each day: /year/day, eg: 2020/01/
# in the dir:
# - code (template files in $skelpath, with YEAR and DAY replaced to
# corresponding year, and the non-zero-padded day, eg: YEAR=2020. DAY=1
# thoughout the file)
#
# ** if current time > selected event's starting time **
# - puzzle.md - when puzzle not fully solved, this file contains the puzzle
# description, untouched obtained from aoc-cli (cargo).
# when puzzle fully solved, the file is modified using .editdesc.vim, and
# renamed to README.md
#
# - input.txt - input data obtained from aocd (pip). this file is generated
# if haven't already
#
# ** OTHERWISE **
# option to exit script, or keep waiting with live timer (see waiting function)
#
# -n option runs the script as usual but skips the steps where network requests
# are made, or files are modified.
#
# use direnv to setup environment variables -- https://direnv.net
# (...pssst... kudos to direnv for supporting fish! *glares at nvm*)
# eg: root git dir in ~/src/adventofcode, set $AOCROOT to ~/src/adventofcode in
# .envrc of ~/src set $SKELAPTH to $AOCROOT/skel/ in .envrc of
# ~/src/adventofcode.
# also optionally add this script path to PATH in the local .envrc
#
#
# NOTE:
# this script is not tested on the plethora of linux distros and terminal
# emulators and the fancy fancy shells. it works for me, and my limited use
# cases. it's best to use this script only if your AoC code directory structure
# is similar to mine, and your dotfiles setup is also similar to mine. the git
# repos for both of which can be found on the git forge of which you got this
# script's src from.
#
# by the way, I'm fully aware of the inconsistent naming and capitalization
# conventions (lol)
#
# do check out my dotfiles if you wish to lay your eyes on some more ridiculously
# unorganized, unidiomatic bash scripts. those are more likely to be
# cross-platform-tested
#
# questions/comments? open an issue or a ticket on the git forge you got this
# source from, or drop me an email (also found on my profile of the git forge
# you got this source from)
#
# BEGIN...unlinted, jumbled mess of bash code...
#
help () {
export LC_TIME=en_US.UTF8 # because month names are hardcoded in english :)
# print the help message
printhelp () {
cat <<END
usage: $(basename $0) [ -h|--help ] [ -n ] [day] [year]
initializes directory \$aocroot/year/day with files in \$skelpath/*
and puzzle description, input.txt files depending on current time
options:
-h/--help: this
-n: dry-run
-h/--help
-n: dry-run (run script but don't modify any files
or create new ones)
arguments:
day: zero padded, two digit
year: 4-digit year
day: *zero padded*, two-digit (eg: 02 (for day 2))
year: 4-digit year (eg: 2017)
description:
initializes directory (aocroot) $aocroot/year/day
with files in (skelpath) $skelpath/*
current env:
\$aocroot: (AOCROOT variable) $aocroot (defaults to CWD)
\$skelpath: (AOC_SKELPATH variable) $skelpath (defaults to \$aocroot/skel/)
customization: env variables \$AOCROOT and \$AOC_SKELPATH
today is $year/$day
today is $(printtoday)
customization: (env variables)
\$AOCROOT: root git dir of AoC repo (eg: \$HOME/src/adventofcode)
\$AOC_SKELPATH: path to template files (eg: \$HOME/src/adventofcode/skel)
***
further documentation? check the source code :P
END
exit
}
# print today is 'year/day' format. If current month is not december: then
# 'year mon day' format
printtoday () {
echo -n "$today_year"
if ! [ $today_month = Dec ]; then
echo -n " $today_month "
else
echo -n "/"
fi
echo $today_day
}
# print a log string if dry run flag used
log () {
if [ "$dryrun" = 1 ]; then
echo "[DRY-RUN] $1"
fi
}
# initialize env
year=$(date '+%Y')
day=$(date '+%d')
today_year=$year
today_day=$day
today_month=$(date '+%b')
skelpath=$AOC_SKELPATH
aocroot=$AOCROOT
@ -37,59 +123,374 @@ if [ -z "$skelpath" ]; then
skelpath=$aocroot/skel
fi
# arg parse
dayarg="$1"
yeararg="$2"
if [ "$1" = "-h" -o "$1" = "--help" ]; then
help
fi
if [ "$1" = "-n" ]; then
dryrun=1
dayarg="$2"
yeararg="$3"
fi
# apply args
if [ -n "$dayarg" ]; then
day="$2"
fi
dayNo0=$((10#$day))
if [ -n "$yeararg" ]; then
year="$3"
fi
dirpath=$aocroot/$year/$day
# env info
echo "ENV: year/day: $year/$day"
echo "ENV: aocroot: $aocroot"
echo "ENV: skelpath: $skelpath"
envinfo () {
echo "ENV: TODAY: $(printtoday)"
echo "ENV: year/day: $year/$day"
echo "ENV: aocroot: $aocroot"
echo "ENV: skelpath: $skelpath"
}
# begin initialization
if [ -e $dirpath ]; then
if [ -n "$(ls -A $dirpath)" ]; then
echo WARNING: $year/$day/ exists and is non-empty
fi
fi
for file in $(find $skelpath -type f -print); do
echo INFO: found skel file $(basename $skelpath)/$(basename $file)
if ! [ -e $dirpath ]; then
if [ "$dryrun" = 1 ]; then
echo "(dry run) $dirpath will be created"
# Create year/day/ folder
initdirs () {
if [ -e $dirpath ]; then
if [ -n "$(ls -A $dirpath)" ]; then
echo "WARNING: $year/$day/ exists and is non-empty"
echo -e "\n--- Directory listing:"
ls $dirpath
echo "--- End of directory listing"
read -p "Proceed? [Y/n] " option
if [[ "$option" == "n" ]]; then
echo "exiting"
exit
fi
else
echo mkdir -p $dirpath
mkdir -p $dirpath
log "$year/$day exists but is empty"
fi
return
fi
filename=$(basename $file)
if [ -e $dirpath/$filename ]; then
echo WARNING: $year/$day/$filename exists
else
if [ "$dryrun" = 1 ]; then
echo "(dry run) $dirpath/$filename will be created"
else
log "$dirpath will be created"
if ! [ "$dryrun" = 1 ]; then
echo mkdir -p $dirpath
mkdir -p $dirpath
fi
}
# Generate code files using templates
templatefiles () {
for file in $(find $skelpath -type f -print); do
filename=$(basename $file)
echo INFO: found skel file $(basename $skelpath)/$filename
if [ -e $dirpath/$filename ]; then
echo WARNING: $year/$day/$filename exists, skipping
continue
fi
log "$dirpath/$filename will be created"
if ! [ "$dryrun" = 1 ]; then
sed -e "s/YEAR/$year/g" -e "s/DAY/$dayNo0/g" $file > $dirpath/$filename
echo initialized $dirpath/$(basename $file)
fi
done
}
# Keep waiting if it's not time yet. Return when puzzle has been released
# or quit upon user request
waiting () {
export TZ=UTC
now=$(date '+%s')
echo "ENV: selected event: UTC $year-12-${day}T05:00:00"
echo "ENV: current time : UTC $(date '+%Y-%m-%dT%T')"
if (( $now < $aoctime )); then
# not yet AoC!
echo "********************"
echo " It's not time yet!"
echo "********************"
echo -e "\nPress enter to keep waiting. q or ^C to quit"
read -p "> " option
if [[ "$option" = q ]]; then
exit
fi
echo
while (( $now < $aoctime )); do
timeleft
sleep 1
tput cuu1 # move cursor up by one line
tput el # clear the line
done
echo
fi
done
echo "Current event puzzle has been released!"
echo "View on the web:"
echo "https://adventofcode.com/$year/day/$dayNo0"
}
# print time left until the selected event puzzle releases
timeleft () {
left=$((aoctime - $(date '+%s'))) # seconds left
days=$(($(date -d"@$left" "+%d") - 1)) # convert it to days
if (( $days > 0 )); then
daystr="$days days, "
if (( $days == 1 )); then
daystr="1 day, "
fi
fi
timestr=$(date -d"@$left" "+%T") # hh:mm:ss time left
echo "$daystr$timestr"
}
# puzzle.md
# Use --no-inspect to skip inspection with editor
puzzlefile () {
if ! command -v aoc &> /dev/null; then
echo "ERROR: command aoc (aoc-cli) not found"
echo "https://github.com/scarvalhojr/aoc-cli"
return
fi
if [ -e $dirpath/README.md ]; then
echo "WARNING: $year/$day/README.md exists"
if grep 'Part Two ---' $dirpath/README.md &> /dev/null; then
echo "INFO: The file appears to be ready"
if ! [ "$1" = --no-inspect ]; then
echo "Inspect README.md with ${EDITOR:-nano}..."
read -p "(press enter to continue) "
${EDITOR:-nano} $dirpath/README.md
fi
echo "What would you like to do?"
cat <<EOF
1. Skip puzzle description file creation
(choose if README.md is all set)
2. Rename README.md to puzzle.md and proceed
(choose if README.md is not the full puzzle)
3. Rename README.md to puzzle.md and skip to next task
(choose if README.md is not the full puzzle, but don't update it right now)
4. Delete README.md and proceed [DEFAULT]
(initialize puzzle.md from scratch, remove README.md)
5. Enter shell to examine environment then restart
q. ABORT (quit the script)
EOF
read -p "1/2/3/4/5/q> " option
case "$option" in
"1")
log "puzzle.md will be skipped"
return
;;
"2"|"3")
log "README.md will be renamed to puzzle.md"
if ! [ "$dryrun" = 1 ]; then
echo mv $dirpath/README.md $dirpath/puzzle.md
mv $dirpath/README.md $dirpath/puzzle.md
fi
if [ "$option" = 3 ]; then
log "leaving puzzle.md task"
return
fi
;;
"4"|"")
log "README.md will be deleted"
if ! [ "$dryrun" = 1 ]; then
echo rm $dirpath/README.md
rm $dirpath/README.md
fi
;;
"5")
echo "Entering $SHELL"
echo "Exit with a non-zero code to quit after the shell quits."
if ! $SHELL; then
log "exiting"
exit
fi
return 1 # restart function (see 'main' later)
;;
"q")
log "exiting"
exit
;;
*)
echo "ERROR: Unknown option"
return 1
;;
esac
else
echo 'INFO: "Part Two ---" not found in README.md'
log "README.md will be deleted"
if ! [ "$dryrun" = 1 ]; then
echo rm $dirpath/README.md
rm $dirpath/README.md
fi
fi
fi
if [ -e $dirpath/puzzle.md ]; then
echo "INFO: puzzle.md exists"
if grep 'Part Two ---' $dirpath/puzzle.md &> /dev/null; then
echo INFO: Part One appears to be solved
puzzledesc_p1_post -u
return
fi
echo "INFO: Part One does not appear to be solved"
echo "INFO: Attempting to update puzzle.md, assuming Part One is solved"
puzzledesc_p1
return
fi
log "puzzle.md does not exist yet"
log "puzzle.md will be generated using aoc-cli"
log "$aocroot/.editdesc.vim will be sourced if both parts of puzzle are complete"
if ! [ "$dryrun" = 1 ]; then
echo INFO: Generating puzzle.md
puzzledesc_p1
return
fi
}
# Entry point for either puzzle.md does not exist yet, or part one not solved yet
puzzledesc_p1 () {
log "puzzle.md will be refreshed with aoc"
if ! [ "$dryrun" = 1 ]; then
if aoc -y $year -d $day -o -p $dirpath/puzzle.md | grep 'Part Two ---' &> /dev/null; then
echo "INFO: Part One now appears to be solved"
puzzledesc_p1_post
return
fi
echo "INFO: Part One does not appear to be solved"
echo "Stopping"
return
fi
}
# Update puzzle.md for part two description - verifying part one is solved
# if -u flag not used, proceed to updating for part two
puzzledesc_p1_post () {
if grep 'this puzzle are complete!' $dirpath/puzzle.md &> /dev/null; then
echo INFO: Part Two appears to be solved
log "puzzle.md will be modified using .editdesc.vim"
log "puzzle.md will be renamed to README.md"
if ! [ "$dryrun" = 1 ]; then
vim $dirpath/puzzle.md "+so $aocroot/.editdesc.vim" "+wq"
echo mv $dirpath/puzzle.md $dirpath/README.md
mv $dirpath/puzzle.md $dirpath/README.md
fi
return
fi
if ! [[ "$1" = "-u" ]]; then
return
fi
puzzledesc_p2_post
}
# Update puzzle.md for part two answer info - verifying part two is solved. If
# so, source .editdesc.vim and rename it to puzzle.md
puzzledesc_p2_post () {
log "will attempt to update puzzle.md using aoc for part two answer information"
if ! [ "$dryrun" = 1 ]; then
echo INFO: attempting to update puzzle.md, assuming Part Two is solved
if aoc -y $year -d $day -o -p $dirpath/puzzle.md | grep 'this puzzle are complete!' &> /dev/null; then
echo "INFO: puzzle.md updated as Part Two is solved"
echo vim $dirpath/puzzle.md "+so $aocroot/.editdesc.vim" "+wq"
vim $dirpath/puzzle.md "+so $aocroot/.editdesc.vim" "+wq"
echo mv $dirpath/puzzle.md $dirpath/README.md
mv $dirpath/puzzle.md $dirpath/README.md
return
fi
echo "INFO: Part Two is not solved yet. Not renaming puzzle.md"
fi
}
# save input data at input.txt, using aocd
inputfile () {
if [[ -e $dirpath/input.txt ]]; then
if [ "$(wc -l $dirpath/input.txt | cut -d " " -f1)" = 0 ]; then
echo WARNING: input.txt exists but is empty. It will be regenerated
else
echo WARNING: input.txt exists and is non-empty. It will be left untouched
return
fi
fi
# aocd command
if ! command -v aocd &> /dev/null; then
echo WARNING: aocd command not found. Attempting to source venv activation script
if ! [[ -e $aocroot/venv/bin/activate ]]; then
echo "ERROR: $aocroot/venv/bin/activate not found"
echo " input.txt creation will be skipped"
return
fi
log "$aocroot/venv/bin/activate will be sourced"
log "if aocd command exists, $year/$day/input.txt will be created"
if ! [ "$dryrun" = 1 ]; then
echo source $aocroot/venv/bin/activate
source $aocroot/venv/bin/activate
if ! command -v aocd &> /dev/null; then
echo ERROR: Activation script sourced, but aocd command not found.
echo " please 'pip install advent-of-code-data'"
echo " input.txt creation will be skipped"
return
fi
fi
else
log "aocd command is found, input.txt will be created"
fi
if ! [ "$dryrun" = 1 ]; then
echo "aocd $dayNo0 $year > $dirpath/input.txt"
aocd $dayNo0 $year > $dirpath/input.txt
fi
}
### main ###############################################################
# stupid arg parse lol
if [ "$1" = "-h" -o "$1" = "--help" ]; then
printhelp
exit
fi
if [ "$1" = "-n" ]; then
dryrun=1
shift
fi
dayarg="$1"
yeararg="$2"
# apply args
if [ -n "$dayarg" ]; then
day="$dayarg"
fi
if [ -n "$yeararg" ]; then
year="$yeararg"
fi
# check args
if ! [[ "$year" =~ ^20[0-9]{2}$ ]]; then
echo "ERROR: year argument must match ^20[0-9]{2}$"
exit 1
fi
if ! (( $year >= 2015 )); then
echo "ERROR: year argument must be 2015 or after"
exit 1
fi
if ! [[ "$day" =~ ^[0-9]{2}$ ]]; then
echo "ERROR: year argument must match ^[0-9]{2}$"
echo "(for single-digit day, zero-pad it, eg: 02)"
exit 1
fi
# non-zero-padded day
dayNo0=$((10#$day))
if ! (( $dayNo0 <= 25 )) && (( $dayNo0 > 0 )); then
echo "ERROR: day must be <= 25"
exit 1
fi
# Vamos >>> We're all set!
dirpath=$aocroot/$year/$day
export aoctime=$(date -d"$year-12-${day}T5:00" '+%s')
echo "Printing env"
envinfo
echo -e "\nInitializing direcotry $year/$day"
initdirs
echo -e "\nCopying template files"
templatefiles
echo -e "\nChecking local time"
waiting
echo -e "\nCreating puzzle description file"
if ! puzzlefile; then
while ! puzzlefile --no-inspect; do
echo -e "Restarting task: puzzlefile \n"
done
fi
echo -e "\nCreating puzzle input data file"
inputfile