Add puzzle text and input for 2022 Day 8-25

This commit is contained in:
Jake Pullen
2023-12-06 07:46:26 +00:00
parent 22ab280ff9
commit e7e80c9034
36 changed files with 14329 additions and 36 deletions
+140 -1
View File
@@ -1 +1,140 @@
Paste any inputs into this file. addx 1
addx 4
addx -2
addx 3
addx 3
addx 1
noop
addx 5
noop
noop
noop
addx 5
addx 2
addx 3
noop
addx 2
addx 4
noop
addx -1
noop
addx 3
addx -10
addx -17
noop
addx -3
addx 2
addx 25
addx -24
addx 2
addx 5
addx 2
addx 3
noop
addx 2
addx 14
addx -9
noop
addx 5
noop
noop
addx -2
addx 5
addx 2
addx -5
noop
noop
addx -19
addx -11
addx 5
addx 3
noop
addx 2
addx 3
addx -2
addx 2
noop
addx 3
addx 4
noop
noop
addx 5
noop
noop
noop
addx 5
addx -3
addx 8
noop
addx -15
noop
addx -12
addx -9
noop
addx 6
addx 7
addx -6
addx 4
noop
noop
noop
addx 4
addx 1
addx 5
addx -11
addx 29
addx -15
noop
addx -12
addx 17
addx 7
noop
noop
addx -32
addx 3
addx -8
addx 7
noop
addx -2
addx 5
addx 2
addx 6
addx -8
addx 5
addx 2
addx 5
addx 17
addx -12
addx -2
noop
noop
addx 7
addx 9
addx -8
addx 2
addx -33
addx -1
addx 2
noop
addx 26
addx -22
addx 19
addx -16
addx 8
addx -1
addx 3
addx -2
addx 2
addx -17
addx 24
addx 1
noop
addx 5
addx -1
noop
addx 5
noop
noop
addx 1
noop
noop
+184 -1
View File
@@ -1 +1,184 @@
# Day 10 Puzzle Text.
<article class="day-desc"><h2>--- Day 10: Cathode-Ray Tube ---</h2><p>You avoid the ropes, plunge into the river, and swim to shore.</p>
<p>The Elves yell something about meeting back up with them upriver, but the river is too loud to tell exactly what they're saying. They finish crossing the bridge and disappear from view.</p>
<p>Situations like this must be why the Elves prioritized getting the communication system on your handheld device working. You pull it out of your pack, but the amount of water slowly draining from a big crack in its screen tells you it probably won't be of much immediate use.</p>
<p><em>Unless</em>, that is, you can design a replacement for the device's video system! It seems to be some kind of <a href="https://en.wikipedia.org/wiki/Cathode-ray_tube" target="_blank">cathode-ray tube</a> screen and simple CPU that are both driven by a precise <em>clock circuit</em>. The clock circuit ticks at a constant rate; each tick is called a <em>cycle</em>.</p>
<p>Start by figuring out the signal being sent by the CPU. The CPU has a single register, <code>X</code>, which starts with the value <code>1</code>. It supports only two instructions:</p>
<ul>
<li><code>addx V</code> takes <em>two cycles</em> to complete. <em>After</em> two cycles, the <code>X</code> register is increased by the value <code>V</code>. (<code>V</code> can be negative.)</li>
<li><code>noop</code> takes <em>one cycle</em> to complete. It has no other effect.</li>
</ul>
<p>The CPU uses these instructions in a program (your puzzle input) to, somehow, tell the screen what to draw.</p>
<p>Consider the following small program:</p>
<pre><code>noop
addx 3
addx -5
</code></pre>
<p>Execution of this program proceeds as follows:</p>
<ul>
<li>At the start of the first cycle, the <code>noop</code> instruction begins execution. During the first cycle, <code>X</code> is <code>1</code>. After the first cycle, the <code>noop</code> instruction finishes execution, doing nothing.</li>
<li>At the start of the second cycle, the <code>addx 3</code> instruction begins execution. During the second cycle, <code>X</code> is still <code>1</code>.</li>
<li>During the third cycle, <code>X</code> is still <code>1</code>. After the third cycle, the <code>addx 3</code> instruction finishes execution, setting <code>X</code> to <code>4</code>.</li>
<li>At the start of the fourth cycle, the <code>addx -5</code> instruction begins execution. During the fourth cycle, <code>X</code> is still <code>4</code>.</li>
<li>During the fifth cycle, <code>X</code> is still <code>4</code>. After the fifth cycle, the <code>addx -5</code> instruction finishes execution, setting <code>X</code> to <code>-1</code>.</li>
</ul>
<p>Maybe you can learn something by looking at the value of the <code>X</code> register throughout execution. For now, consider the <em>signal strength</em> (the cycle number multiplied by the value of the <code>X</code> register) <em>during</em> the 20th cycle and every 40 cycles after that (that is, during the 20th, 60th, 100th, 140th, 180th, and 220th cycles).</p>
<p>For example, consider this larger program:</p>
<pre><code>addx 15
addx -11
addx 6
addx -3
addx 5
addx -1
addx -8
addx 13
addx 4
noop
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx 5
addx -1
addx -35
addx 1
addx 24
addx -19
addx 1
addx 16
addx -11
noop
noop
addx 21
addx -15
noop
noop
addx -3
addx 9
addx 1
addx -3
addx 8
addx 1
addx 5
noop
noop
noop
noop
noop
addx -36
noop
addx 1
addx 7
noop
noop
noop
addx 2
addx 6
noop
noop
noop
noop
noop
addx 1
noop
noop
addx 7
addx 1
noop
addx -13
addx 13
addx 7
noop
addx 1
addx -33
noop
noop
noop
addx 2
noop
noop
noop
addx 8
noop
addx -1
addx 2
addx 1
noop
addx 17
addx -9
addx 1
addx 1
addx -3
addx 11
noop
noop
addx 1
noop
addx 1
noop
noop
addx -13
addx -19
addx 1
addx 3
addx 26
addx -30
addx 12
addx -1
addx 3
addx 1
noop
noop
noop
addx -9
addx 18
addx 1
addx 2
noop
noop
addx 9
noop
noop
noop
addx -1
addx 2
addx -37
addx 1
addx 3
noop
addx 15
addx -21
addx 22
addx -6
addx 1
noop
addx 2
addx 1
noop
addx -10
noop
noop
addx 20
addx 1
addx 2
addx 2
addx -6
addx -11
noop
noop
noop
</code></pre>
<p>The interesting signal strengths can be determined as follows:</p>
<ul>
<li>During the 20th cycle, register <code>X</code> has the value <code>21</code>, so the signal strength is 20 * 21 = <em>420</em>. (The 20th cycle occurs in the middle of the second <code>addx -1</code>, so the value of register <code>X</code> is the starting value, <code>1</code>, plus all of the other <code>addx</code> values up to that point: 1 + 15 - 11 + 6 - 3 + 5 - 1 - 8 + 13 + 4 = 21.)</li>
<li>During the 60th cycle, register <code>X</code> has the value <code>19</code>, so the signal strength is 60 * 19 = <code><em>1140</em></code>.</li>
<li>During the 100th cycle, register <code>X</code> has the value <code>18</code>, so the signal strength is 100 * 18 = <code><em>1800</em></code>.</li>
<li>During the 140th cycle, register <code>X</code> has the value <code>21</code>, so the signal strength is 140 * 21 = <code><em>2940</em></code>.</li>
<li>During the 180th cycle, register <code>X</code> has the value <code>16</code>, so the signal strength is 180 * 16 = <code><em>2880</em></code>.</li>
<li>During the 220th cycle, register <code>X</code> has the value <code>18</code>, so the signal strength is 220 * 18 = <code><em>3960</em></code>.</li>
</ul>
<p>The sum of these signal strengths is <code><em>13140</em></code>.</p>
<p>Find the signal strength during the 20th, 60th, 100th, 140th, 180th, and 220th cycles. <em>What is the sum of these six signal strengths?</em></p>
+55 -1
View File
@@ -1 +1,55 @@
Paste any inputs into this file. Monkey 0:
Starting items: 59, 74, 65, 86
Operation: new = old * 19
Test: divisible by 7
If true: throw to monkey 6
If false: throw to monkey 2
Monkey 1:
Starting items: 62, 84, 72, 91, 68, 78, 51
Operation: new = old + 1
Test: divisible by 2
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 78, 84, 96
Operation: new = old + 8
Test: divisible by 19
If true: throw to monkey 6
If false: throw to monkey 5
Monkey 3:
Starting items: 97, 86
Operation: new = old * old
Test: divisible by 3
If true: throw to monkey 1
If false: throw to monkey 0
Monkey 4:
Starting items: 50
Operation: new = old + 6
Test: divisible by 13
If true: throw to monkey 3
If false: throw to monkey 1
Monkey 5:
Starting items: 73, 65, 69, 65, 51
Operation: new = old * 17
Test: divisible by 11
If true: throw to monkey 4
If false: throw to monkey 7
Monkey 6:
Starting items: 69, 82, 97, 93, 82, 84, 58, 63
Operation: new = old + 5
Test: divisible by 5
If true: throw to monkey 5
If false: throw to monkey 7
Monkey 7:
Starting items: 81, 78, 82, 76, 79, 80
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 3
If false: throw to monkey 4
+208 -1
View File
@@ -1 +1,208 @@
# Day 11 Puzzle Text.
<article class="day-desc"><h2>--- Day 11: Monkey in the Middle ---</h2><p>As you finally start making your way upriver, you realize your pack is much lighter than you remember. Just then, one of the items from your pack goes flying overhead. Monkeys are playing <a href="https://en.wikipedia.org/wiki/Keep_away" target="_blank">Keep Away</a> with your missing things!</p>
<p>To get your stuff back, you need to be able to predict where the monkeys will throw your items. After some careful observation, you realize the monkeys operate based on <em>how worried you are about each item</em>.</p>
<p>You take some notes (your puzzle input) on the items each monkey currently has, how worried you are about those items, and how the monkey makes decisions based on your worry level. For example:</p>
<pre><code>Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1
</code></pre>
<p>Each monkey has several attributes:</p>
<ul>
<li><code>Starting items</code> lists your <em>worry level</em> for each item the monkey is currently holding in the order they will be inspected.</li>
<li><code>Operation</code> shows how your worry level changes as that monkey inspects an item. (An operation like <code>new = old * 5</code> means that your worry level after the monkey inspected the item is five times whatever your worry level was before inspection.)</li>
<li><code>Test</code> shows how the monkey uses your worry level to decide where to throw an item next.
<ul>
<li><code>If true</code> shows what happens with an item if the <code>Test</code> was true.</li>
<li><code>If false</code> shows what happens with an item if the <code>Test</code> was false.</li>
</ul>
</li>
</ul>
<p>After each monkey inspects an item but before it tests your worry level, your relief that the monkey's inspection didn't damage the item causes your worry level to be <em>divided by three</em> and rounded down to the nearest integer.</p>
<p>The monkeys take turns inspecting and throwing items. On a single monkey's <em>turn</em>, it inspects and throws all of the items it is holding one at a time and in the order listed. Monkey <code>0</code> goes first, then monkey <code>1</code>, and so on until each monkey has had one turn. The process of each monkey taking a single turn is called a <em>round</em>.</p>
<p>When a monkey throws an item to another monkey, the item goes on the <em>end</em> of the recipient monkey's list. A monkey that starts a round with no items could end up inspecting and throwing many items by the time its turn comes around. If a monkey is holding no items at the start of its turn, its turn ends.</p>
<p>In the above example, the first round proceeds as follows:</p>
<pre><code>Monkey 0:
Monkey inspects an item with a worry level of 79.
Worry level is multiplied by 19 to 1501.
Monkey gets bored with item. Worry level is divided by 3 to 500.
Current worry level is not divisible by 23.
Item with worry level 500 is thrown to monkey 3.
Monkey inspects an item with a worry level of 98.
Worry level is multiplied by 19 to 1862.
Monkey gets bored with item. Worry level is divided by 3 to 620.
Current worry level is not divisible by 23.
Item with worry level 620 is thrown to monkey 3.
Monkey 1:
Monkey inspects an item with a worry level of 54.
Worry level increases by 6 to 60.
Monkey gets bored with item. Worry level is divided by 3 to 20.
Current worry level is not divisible by 19.
Item with worry level 20 is thrown to monkey 0.
Monkey inspects an item with a worry level of 65.
Worry level increases by 6 to 71.
Monkey gets bored with item. Worry level is divided by 3 to 23.
Current worry level is not divisible by 19.
Item with worry level 23 is thrown to monkey 0.
Monkey inspects an item with a worry level of 75.
Worry level increases by 6 to 81.
Monkey gets bored with item. Worry level is divided by 3 to 27.
Current worry level is not divisible by 19.
Item with worry level 27 is thrown to monkey 0.
Monkey inspects an item with a worry level of 74.
Worry level increases by 6 to 80.
Monkey gets bored with item. Worry level is divided by 3 to 26.
Current worry level is not divisible by 19.
Item with worry level 26 is thrown to monkey 0.
Monkey 2:
Monkey inspects an item with a worry level of 79.
Worry level is multiplied by itself to 6241.
Monkey gets bored with item. Worry level is divided by 3 to 2080.
Current worry level is divisible by 13.
Item with worry level 2080 is thrown to monkey 1.
Monkey inspects an item with a worry level of 60.
Worry level is multiplied by itself to 3600.
Monkey gets bored with item. Worry level is divided by 3 to 1200.
Current worry level is not divisible by 13.
Item with worry level 1200 is thrown to monkey 3.
Monkey inspects an item with a worry level of 97.
Worry level is multiplied by itself to 9409.
Monkey gets bored with item. Worry level is divided by 3 to 3136.
Current worry level is not divisible by 13.
Item with worry level 3136 is thrown to monkey 3.
Monkey 3:
Monkey inspects an item with a worry level of 74.
Worry level increases by 3 to 77.
Monkey gets bored with item. Worry level is divided by 3 to 25.
Current worry level is not divisible by 17.
Item with worry level 25 is thrown to monkey 1.
Monkey inspects an item with a worry level of 500.
Worry level increases by 3 to 503.
Monkey gets bored with item. Worry level is divided by 3 to 167.
Current worry level is not divisible by 17.
Item with worry level 167 is thrown to monkey 1.
Monkey inspects an item with a worry level of 620.
Worry level increases by 3 to 623.
Monkey gets bored with item. Worry level is divided by 3 to 207.
Current worry level is not divisible by 17.
Item with worry level 207 is thrown to monkey 1.
Monkey inspects an item with a worry level of 1200.
Worry level increases by 3 to 1203.
Monkey gets bored with item. Worry level is divided by 3 to 401.
Current worry level is not divisible by 17.
Item with worry level 401 is thrown to monkey 1.
Monkey inspects an item with a worry level of 3136.
Worry level increases by 3 to 3139.
Monkey gets bored with item. Worry level is divided by 3 to 1046.
Current worry level is not divisible by 17.
Item with worry level 1046 is thrown to monkey 1.
</code></pre>
<p>After round 1, the monkeys are holding items with these worry levels:</p>
<pre><code>Monkey 0: 20, 23, 27, 26
Monkey 1: 2080, 25, 167, 207, 401, 1046
Monkey 2:
Monkey 3:
</code></pre>
<p>Monkeys 2 and 3 aren't holding any items at the end of the round; they both inspected items during the round and threw them all before the round ended.</p>
<p>This process continues for a few more rounds:</p>
<pre><code>After round 2, the monkeys are holding items with these worry levels:
Monkey 0: 695, 10, 71, 135, 350
Monkey 1: 43, 49, 58, 55, 362
Monkey 2:
Monkey 3:
After round 3, the monkeys are holding items with these worry levels:
Monkey 0: 16, 18, 21, 20, 122
Monkey 1: 1468, 22, 150, 286, 739
Monkey 2:
Monkey 3:
After round 4, the monkeys are holding items with these worry levels:
Monkey 0: 491, 9, 52, 97, 248, 34
Monkey 1: 39, 45, 43, 258
Monkey 2:
Monkey 3:
After round 5, the monkeys are holding items with these worry levels:
Monkey 0: 15, 17, 16, 88, 1037
Monkey 1: 20, 110, 205, 524, 72
Monkey 2:
Monkey 3:
After round 6, the monkeys are holding items with these worry levels:
Monkey 0: 8, 70, 176, 26, 34
Monkey 1: 481, 32, 36, 186, 2190
Monkey 2:
Monkey 3:
After round 7, the monkeys are holding items with these worry levels:
Monkey 0: 162, 12, 14, 64, 732, 17
Monkey 1: 148, 372, 55, 72
Monkey 2:
Monkey 3:
After round 8, the monkeys are holding items with these worry levels:
Monkey 0: 51, 126, 20, 26, 136
Monkey 1: 343, 26, 30, 1546, 36
Monkey 2:
Monkey 3:
After round 9, the monkeys are holding items with these worry levels:
Monkey 0: 116, 10, 12, 517, 14
Monkey 1: 108, 267, 43, 55, 288
Monkey 2:
Monkey 3:
After round 10, the monkeys are holding items with these worry levels:
Monkey 0: 91, 16, 20, 98
Monkey 1: 481, 245, 22, 26, 1092, 30
Monkey 2:
Monkey 3:
...
After round 15, the monkeys are holding items with these worry levels:
Monkey 0: 83, 44, 8, 184, 9, 20, 26, 102
Monkey 1: 110, 36
Monkey 2:
Monkey 3:
...
After round 20, the monkeys are holding items with these worry levels:
Monkey 0: 10, 12, 14, 26, 34
Monkey 1: 245, 93, 53, 199, 115
Monkey 2:
Monkey 3:
</code></pre>
<p>Chasing all of the monkeys at once is impossible; you're going to have to focus on the <em>two most active</em> monkeys if you want any hope of getting your stuff back. Count the <em>total number of times each monkey inspects items</em> over 20 rounds:</p>
<pre><code><em>Monkey 0 inspected items 101 times.</em>
Monkey 1 inspected items 95 times.
Monkey 2 inspected items 7 times.
<em>Monkey 3 inspected items 105 times.</em>
</code></pre>
<p>In this example, the two most active monkeys inspected items 101 and 105 times. The level of <em>monkey business</em> in this situation can be found by multiplying these together: <code><em>10605</em></code>.</p>
<p>Figure out which monkeys to chase by counting how many items they inspect over 20 rounds. <em>What is the level of monkey business after 20 rounds of stuff-slinging simian shenanigans?</em></p>
+41 -1
View File
@@ -1 +1,41 @@
Paste any inputs into this file. abccccccccccccccccccaaaaaaaaacccccccccccccccccccccccccccccccccccccaaaa
abcccccccccccccccaaaaaaaaaaacccccccccccccccccccccccccccccccccccccaaaaa
abcaaccaacccccccccaaaaaaaaaacccccccccccccccccccccaaacccccccccccccaaaaa
abcaaaaaaccccccccaaaaaaaaaaaaacccccccccccccccccccaacccccccccccccaaaaaa
abcaaaaaacccaaacccccaaaaaaaaaaaccccccccccccccccccaaaccccccccccccccccaa
abaaaaaaacccaaaaccccaaaaaacaaaacccccccccccaaaacjjjacccccccccccccccccca
abaaaaaaaaccaaaaccccaaaaaaccccccaccccccccccaajjjjjkkcccccccccccccccccc
abaaaaaaaaccaaacccccccaaaccccccaaccccccccccajjjjjjkkkaaacccaaaccaccccc
abccaaacccccccccccccccaaccccaaaaaaaacccccccjjjjoookkkkaacccaaaaaaccccc
abcccaacccccccccccccccccccccaaaaaaaaccccccjjjjoooookkkkcccccaaaaaccccc
abcccccccaacccccccccccccccccccaaaacccccccijjjoooooookkkkccaaaaaaaccccc
abccaaccaaaccccccccccccccccccaaaaacccccciijjooouuuoppkkkkkaaaaaaaacccc
abccaaaaaaaccccccccccaaaaacccaacaaaccciiiiiooouuuuupppkkklllaaaaaacccc
abccaaaaaacccccccccccaaaaacccacccaaciiiiiiqooouuuuuupppkllllllacaccccc
abcccaaaaaaaacccccccaaaaaaccccaacaiiiiiqqqqoouuuxuuupppppplllllccccccc
abccaaaaaaaaaccaaaccaaaaaaccccaaaaiiiiqqqqqqttuxxxuuuppppppplllccccccc
abccaaaaaaaacccaaaaaaaaaaacccaaaahiiiqqqttttttuxxxxuuuvvpppplllccccccc
abcaaaaaaacccaaaaaaaaaaacccccaaaahhhqqqqtttttttxxxxuuvvvvvqqlllccccccc
abcccccaaaccaaaaaaaaaccccccccacaahhhqqqttttxxxxxxxyyyyyvvvqqlllccccccc
abcccccaaaccaaaaaaaacccccccccccaahhhqqqtttxxxxxxxyyyyyyvvqqqlllccccccc
SbcccccccccccaaaaaaaaaccccccccccchhhqqqtttxxxxEzzzyyyyvvvqqqmmlccccccc
abcccccccccccaaaaaaaacccaacccccccchhhppptttxxxxyyyyyvvvvqqqmmmcccccccc
abccccccccccaaaaaaaaaaccaacccccccchhhpppptttsxxyyyyyvvvqqqmmmccccccccc
abcaacccccccaaaaaaacaaaaaaccccccccchhhppppsswwyyyyyyyvvqqmmmmccccccccc
abaaaacccccccaccaaaccaaaaaaacccccccchhhpppsswwyywwyyyvvqqmmmddcccccccc
abaaaaccccccccccaaaccaaaaaaacccccccchhhpppsswwwwwwwwwvvqqqmmdddccccccc
abaaaacccccccccaaaccaaaaaaccccccccccgggpppsswwwwrrwwwwvrqqmmdddccccccc
abccccccaaaaaccaaaacaaaaaaccccccaacccggpppssswwsrrrwwwvrrqmmdddacccccc
abccccccaaaaaccaaaacccccaaccccaaaaaacggpppssssssrrrrrrrrrnmmdddaaccccc
abcccccaaaaaaccaaaccccccccccccaaaaaacggppossssssoorrrrrrrnnmdddacccccc
abcccccaaaaaaccccccccaaaaccccccaaaaacgggoooossoooonnnrrnnnnmddaaaacccc
abccccccaaaaaccccccccaaaacccccaaaaaccgggoooooooooonnnnnnnnndddaaaacccc
abccccccaaaccccccccccaaaacccccaaaaacccgggoooooooffennnnnnnedddaaaacccc
abcccccccccccccccccccaaacccccccaacccccggggffffffffeeeeeeeeeedaaacccccc
abccccccccccccccccccaaacccccaccaaccccccggfffffffffeeeeeeeeeecaaacccccc
abccccccccccccccccccaaaacccaaaaaaaaaccccfffffffaaaaaeeeeeecccccccccccc
abccccccccaacaaccccaaaaaacaaaaaaaaaaccccccccccaaaccaaaaccccccccccccccc
abccccccccaaaaacccaaaaaaaaaaacaaaaccccccccccccaaaccccaaccccccccccaaaca
abcccccccaaaaaccccaaaaaaaaaaacaaaaacccccccccccaaaccccccccccccccccaaaaa
abcccccccaaaaaacccaaaaaaaaaacaaaaaacccccccccccaaccccccccccccccccccaaaa
abcccccccccaaaaccaaaaaaaaaaaaaaccaaccccccccccccccccccccccccccccccaaaaa
+22 -1
View File
@@ -1 +1,22 @@
# Day 12 Puzzle Text.
<article class="day-desc"><h2>--- Day 12: Hill Climbing Algorithm ---</h2><p>You try contacting the Elves using your <span title="When you look up the specs for your handheld device, every field just says &quot;plot&quot;.">handheld device</span>, but the river you're following must be too low to get a decent signal.</p>
<p>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 <code>a</code> is the lowest elevation, <code>b</code> is the next-lowest, and so on up to the highest elevation, <code>z</code>.</p>
<p>Also included on the heightmap are marks for your current position (<code>S</code>) and the location that should get the best signal (<code>E</code>). Your current position (<code>S</code>) has elevation <code>a</code>, and the location that should get the best signal (<code>E</code>) has elevation <code>z</code>.</p>
<p>You'd like to reach <code>E</code>, but to save energy, you should do it in <em>as few steps as possible</em>. 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 <em>at most one higher</em> than the elevation of your current square; that is, if your current elevation is <code>m</code>, you could step to elevation <code>n</code>, but not to elevation <code>o</code>. (This also means that the elevation of the destination square can be much lower than the elevation of your current square.)</p>
<p>For example:</p>
<pre><code><em>S</em>abqponm
abcryxxl
accsz<em>E</em>xk
acctuvwj
abdefghi
</code></pre>
<p>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 <code>e</code> at the bottom. From there, you can spiral around to the goal:</p>
<pre><code>v..v&lt;&lt;&lt;&lt;
&gt;v.vv&lt;&lt;^
.&gt;vv&gt;E^^
..v&gt;&gt;&gt;^^
..&gt;&gt;&gt;&gt;&gt;^
</code></pre>
<p>In the above diagram, the symbols indicate whether the path exits each square moving up (<code>^</code>), down (<code>v</code>), left (<code>&lt;</code>), or right (<code>&gt;</code>). The location that should get the best signal is still <code>E</code>, and <code>.</code> marks unvisited squares.</p>
<p>This path reaches the goal in <code><em>31</em></code> steps, the fewest possible.</p>
<p><em>What is the fewest steps required to move from your current position to the location that should get the best signal?</em></p>
+449 -1
View File
@@ -1 +1,449 @@
Paste any inputs into this file. [[[1,[1,6,0,10,10],[],5,[]],[3,[5,8],2,[3,6,5,7],8],4,[0,[10]],8],[7,7],[[3,[9,5,10],[3],8,10],2,3,9],[[8,[3,1,4,9,5]]],[[[],0],10,10,3]]
[[],[[[2,1,2,9],[]],[[1,5,10],3]]]
[[],[[1,[0,4,7,10,10],3,[6,2,0],[9,1,4]],[],[5,[0,8,5],0,10,[3,10,10]],2,2],[],[[[],10,[]],[3,3,[0,0,2,10],[7,8,6,4,6],6],[10,[8,2,4,2,0]]],[[[9,2,10],[5],1,5,[2,7,9]],[4,[6]],[[]],[4,[],[6,5]]]]
[[6,[]],[[[1],[6,4,1,4],3],[4,4]],[[6,[2,2,9],5,[8,9,7,10]],6],[5,[[10,9,0,5,5],[10,6,6]],[[10,9,6],[0,0,3,1],[],5],7]]
[[[4,[3,0,5,8,4],[5],7]],[[1,[3,9,10,3],6],7,2]]
[[[]],[],[[[5,7,8,8],[3,1,6,3],[6,7],4],10,8,[5,7,[5,0],9,7],6],[7,[4],7,[8,5],5]]
[[[],4,6],[0,3,2],[[5,[9,0,10,3,7]],[[5,6,7],[6,0]],9,[9]]]
[[[[7,8,9,3,5],6,[2,6],[6,1,4,10,8]],3],[10],[[]]]
[[2,8,[[8,3,1,5]],[[8,3],[1],[3],[],[5,8,8,9,4]]],[10],[],[6]]
[[0,[[6],8,4],6,4],[[[10,2],[6,4,4,9],8,[]],[0,5,4,[4,2,0]],1],[[[0,3,8]],8,0],[]]
[[5],[[],[[9,2,3,5,0],[1,2,7,5],5],0,[[4,8,10],[4,1],[9,1],3,10],3],[]]
[[],[2,[8],[],[2,8,7,[]],[[],[9,10,1,10],[],[]]],[6,[1,[],10,[3,1,5,1,7]],[6,[10,1],[0,10,4],4]],[]]
[[3,[[9,2,7],3,6,[6,9],[3,8,2,5,2]]],[],[[9,[5,8]],6,5,[[10]]]]
[[2,[1,2],[[6]],[6,8,6]],[[],[2,4,[7]],[0,2,[],[0,7,10,7,7],[10,2,8]],10,[[3],[7,4,8],[7,6]]]]
[[[[2,9],0,9,4],0,[[5,10],[0],5,[6,3]]]]
[[[9,1,[]],[[7,9,9,5]],[[3,6,0,1]]],[1,3,1],[0,1,[],[[3]]]]
[[6,6,[[5,8,6],[],[0,7],0]],[8]]
[[0,6,[[0,3]]],[9,[0,7,5,5],[[3,8,2,5],1],4,[10,[4,3],2]],[0],[[6],[1],[6,[],[4,8,6,10,0]]],[2,8,[6,[8],[8,4]]]]
[[7],[[],2,6],[3],[[5,[5,5,5,7],6],[6],1]]
[[1,[3,[8,4,1,0,1]],6,5],[1,[[7],[8,7,5]],8,[[],5],8],[],[[8,[]],5,4],[8]]
[[8]]
[[],[],[[[7,3],[9,0,0,2]]],[[9,0,[6,3,2,0,1],5],3],[[],[10,9]]]
[[[2,[10,10,9,6,7]],[5,1,3,7]],[[10],8,[[1,8,10,8,1],8,[1,2,4,7]]],[]]
[[10],[6,[],6,[[10,1],7,[5,1,0]]],[[0,6,[4,5],[9,0],6],[]]]
[[[],[],[]],[3]]
[[[[]],10],[[[0,9,8,9,4],[4,1,5,4],[7,6],3],10,2,0],[[0,6]],[9,3]]
[[],[[[9,4,8,1],0,8,[10,9]],[]],[[1,7,[5,9,3],8,5],3,[[8,9,10,2],7,[0,10,7],[8]],[5,[8,7,0,3,5],0],[9]]]
[[3,7,10,[[9,1,8],[4,5,0],8,[2,7]],10]]
[[[9,[5,10,3,5,1]],7,9]]
[[9]]
[[[[7,3,4,9,5],6,[4],4],[9,[9,9,3,4,6],5,8],[[1,6,8],[8,9,0,2],10]],[[],[4,[4,7]],3,[7,[],5,7]]]
[[[[0,7,7]],[[4,6,4],[7],4]],[0],[[],[[4,3,1,10,4],[2,0,9]],0],[[[7,1,5,8,9]],5,7,8]]
[[7,10,[5,[5,6,7],2,7],5,[[10,9],2]],[],[[8,[2,9,10],[10],[],[]],[]],[0,[9,0],[[],[4,2,10,6,5]],10]]
[[[[3,0,10,3]]],[[6],10,[1,3,[],0],4,7],[4,[],9,[[3,5,4,9,10],[0,8,3,4],[3,9,8,9],[1]],1]]
[[],[6,[7,5]],[6,6,3]]
[[],[[2,3],5,6],[7,[]]]
[[[],[1,[2]],4,10,[[],[],0,[3,6,10,4]]],[[1]]]
[[7,[5,3,9,[10]]]]
[[],[]]
[[[10],8,9,[4,10,[9,6],[1,0,6,7,8]]],[2,0,[1,2,2,2,6],[5,[3,0,9]]]]
[[4,0,4,2,[]],[0],[8,[8,[1,10],4,1],1,[5,6,2],2],[[5,2],0,3,[[8,4,6,9]]],[[[],9,[],9],[],[[2,5],[5,5,8,4],[4]],7,0]]
[[],[10,[4,5,[3,2,10,0,0],[5,3,6]],1,[2]],[[7,[8,7,3,2]],[5,10,10],[4,[10,7,0,6,10]],8]]
[[[[8]],3,[[2,1],1,4,8,[8]],8],[]]
[[10,9,[[6,3],[9,7,3],[6,8]],2,[[]]],[[[],9,[1,6,3,10]],3,[1,10],0],[[[0,8,5,2],1,2,[7,4]],5,[0,[8,7,1,1],5,2,[6,1,8]],1,[1,[8],[3]]],[[10,[0,7,8],10,8],7,[[]],0,[]],[5,8,1,[[],9,[],[0]],[]]]
[[[3,6,[7,10,0,2]]]]
[[9,[[4,6,10]],1,6,[5,[8,5],5,10,10]],[[],9,1,[2,[5,3],2,[6]]],[4],[],[[0]]]
[[[[7,3,5],[1]],2,[],4],[0],[9,[[4,2,5,9,6],2],[],[5,6]],[2]]
[[3,5,6,[[5],10]],[[2,[8,0,2,5,9],[]],5]]
[[[3],4],[[[2,1],[2,9,6]],[],0,4],[[[7],[7,3],0,8,9],[[10,9,10,6],[2,0,10,1]],9],[10]]
[[[]],[[],8,[[],[5,0],0,2,[3,7,8]]],[3,0,1,2],[],[10,10]]
[[[1,8,6,[9,5,6,6,3]],5,[[9,3,3,10],[8,0,1,9],9,[2]],8],[[[4,0,5],[4,10,7,4,0],9],4],[2],[3,[9,[],4],3,[[],0,7,6]],[]]
[[[0,[]],4],[[4,[5,7,10,5,1],5],[[10]]]]
[[[],[[10,8],[],[8,4]],1,0,[]],[[],[[2,0,8],4,9,7],[10,[0,8,4,9,5]],5]]
[[[10,5,[2,7,8],2],[2],7,[]],[6,2],[3,7,7,[[9,3,5,8,4],[3,0,4],[10,9,4,8,8],[2,4,7],7]],[[]],[1,5,[[10,3,4,1,5],6,[],10]]]
[[],[[[],[3,3,0],[4,0,5],[5]],[10,8,[2],[10,1,10,3],[10,7]],[[1,5,7,0],[8,5],10,8,[10,4,5,10]]],[7,[2,3,9,9]],[[8,[3,9,6]],[[8,8]],0]]
[[8,[9,8,[6]],[[8,7]],[4,6]],[],[],[[0,3,[7,9,6,9,1]],[[],[7,6,2,2,0]]],[[],[[0,2,2,3,7],8,[3,10]],1,[8,0,[6]],6]]
[[4,[1,9],0],[8,[2,[],[10,9,6,5],9,7],[[6,2,7,8],10,2,2,[0,10,2]],7]]
[[],[0],[2,[],[6,2,[4,4],[10,10,3,2,10]],10],[8,[],[8,8],9,10],[[[4,9],[8],0,10]]]
[[[[7],5,[4,2,5,6,6],[3,8,10,10,10],[10,10,9,7,9]],[6,9]],[2,[],[[2,2,9,2,10],[10,9],0,[5,7]]],[[7,2],7],[0,[7],[3,[]],6,3]]
[[5]]
[[[4,10],5]]
[[],[[[],[1,7,10,1,9],2,0,2],2,0],[[],[[8,2,5,4,9],7,8,3,[2,7]],5,0]]
[[10],[],[4,7,7,[[8],[1,8,8,6,10],[10,6,6],2],[4,[3,3,2,7,4],8,8,3]],[[9,[7,9,8,4],7],[[9,1,5,9,5]]]]
[[[7],6,[3,6,9]],[10,5]]
[[[2,[],9,6],4,4],[[[8,2,4],8,[8],[8,4,10]],[[7,6,4,10,9],6,6,3],10,[6,[10,2,3,8,7],4],6],[[],[],[3],[10],5]]
[[4],[[],[[10,9],[0,8,3,5]]],[[[],[2,2,1,10,6]],0,[[1,8]],6],[2,[[10],[6,3],7,[1,3,10]]]]
[[[],[[7,4,7,7]]],[7],[0,[]],[3]]
[[0,[[6,5],[2],0,[],[5]]],[[1]],[]]
[[[10,[7,7],[8,1,0,4,5],7],2,[[],[2,2,8,2],[5,0,9],5,[]],6,[[0,8,10],9,[5,5,6,8,0],[9]]]]
[[3,[[],[4,9,4],6,[5,2,8]]]]
[[[[3,2],2],6,[5,1,6,0],[],4],[[7],4,0,0,[[9,1],6,[8]]],[[6],1],[0,[[4,0]],2],[]]
[[[5,9,5,[],3],[2,6,[0,2,4,4]],0,0,[]],[[[],8]]]
[[[4,0,1,9],5,5]]
[[2,3],[]]
[[5,2,[[],[4,2,9,3]],[1,0,5],[7]],[[10,[3],[5],4],0,6,8,3],[9,[8,5],[4],3],[6,[],[8,9,5,[1,9,4,3,4],9],[2,10],8],[[[3,3,8,0]],8,4,[6,[1,5],[],[7,7]],5]]
[[],[8,5,[9,[5,5,7]],[[9,0,3,1],5,8]],[[]]]
[[],[[[6,2,9]],6],[[],[[]],8],[[[5,1],[0,8],10],[[],0,[4,8],[5],7]],[5,3,[9,[0],[],[3,10,3,6]],[7,3,0],[[1,10,8],7,[0]]]]
[[[],[3,6,4,[10,7,1],9],7,[],[0,[9,2,3],[9]]],[0,[4,4,4,9,2],[[8,5,8,3,10],8,7,5],1,[[6,0],6,0,4]]]
[]
[[],[1,5,8,10,8]]
[[8,7],[[9,4],10,5,2],[7,[[]],10,0,[10,4,[],[4,6,8],0]],[[[],[1,10,4,3],[1],10,[7,9,3,9]],[6,[9,8,7,0],6,[5,9,3,5,7],[8,3,4,1]],[10,7,9],9],[6,[[9,8],8,[2,6,4,9]]]]
[[[[1],[6,9,6,4,0]],[5,[4]],9]]
[[[[10,3,2,9,1],[1],7,2,2]]]
[[5,[[],9,[6,0,9,7,2],1],[]],[[1,2,[6,6],[1,7,1]],7],[[7,[2,5,3]],[0],2],[5,9]]
[[[7],[6],[3,2],[[3,5,2]],1],[[7],[[5,1,0,2],2,[5,7,2,4]],[[10],8]]]
[[[[],[8,2,7,4,4],[10,8]],[3,[3],[4]]],[[0,[10,5,10,4]],[[],[7,8,10,10,3],6],3],[[[10,4],7,[4,0],[7,8,0,10]],[1],[2,2,3,[5,6,8]]],[8,10,[[3,1,8,8],5,9,1,[10,6]],[[4,7],5,[1,9,10,0,4],2]]]
[[2,[4],9,[],[4,10]],[],[[[9],[0,0],[1,4,9,7],0],0,[[1,0,2],7,1],4,2]]
[[[6,10],[3,2,[1,1,7],[1],7]],[2],[1],[]]
[[],[4,[10],[[0,5,8,2,10],[],9,[0,3],[9,1]]],[9,1,8,[[1,10,8,3,4],[6,0,5,7,9],[2,10,3],3],6],[0,[10,[],2],5]]
[[[[10,3,9,2,5],2,[],3],10],[[[7,3,8,9,10],5,6,6,[1]],10,3,4,[[1],10,7]],[[[1,8,4,2,10],6,9,0,[]]],[[5,9]]]
[[[3,10,3,10]],[[6,7,[2,8,9,6,5]],6],[10],[6,[],[7,[8,9,4,2]]]]
[[[[9,7],[2]],[5],[]],[[[4,7,7],7,0],7,[[8,0],[],[4,5,6,2],[]]]]
[[]]
[[10,[]],[1],[],[[[8]]]]
[[[[5,0,4,10,0],5,[],[1]],[],[2],[[2,2,7,1,2],7,1,0,4],[10,[],5]],[[6,[5,9,6,3],3,9,[8,4,1,8]],[[3,3,8,3,0]],[6,[],0,[4,2],[]]]]
[[3],[[4,[8,4,10],7],[6,[5,9,9,2,4],[9,1,7,0],[5,9,5,0]],[4,10,[],[8,8,7]],1,10]]
[[[1,[8],[2,7,1],9],[],[9,1],[2,10,[8,10,7]],5]]
[[3,[]],[[],[9,9],0,8,[[8,8,1,5,6],[3,8,4,5,4]]],[[4,7,10,[7,2,0,0]],[[9]]]]
[[3],[4,7],[],[[1],[[4,9,10]],[[]],[],4],[[4,1],0,2,2,[2,[],[8,2,10],[9,0,10,4]]]]
[[5,9,[1,[0,9,10]],[1,9],7],[7,6,[[6,9],0],8],[1],[[6,7,3]],[]]
[[[8,4,[5,2]],0,[],8],[],[9],[[],[6,1,[3,0,7],1],[[9],7,[7],10]],[]]
[[2,[[1,2,8,8],[]],2,4,6],[[7]],[9,[10,[10,1,3,3,3],[3,10,10],5,7],7],[],[]]
[[10,1],[10,[[9],[9,1,5,9,5],[7,7,9,0],6]]]
[[[4,[10],1,[0,1]]],[[[7],9],6,9,6,6]]
[[6,[[],6,[7,8,8]]],[[1,3,[4,8,0,6],[1,10,3,9],10],[6,3],[9]],[],[[],[0,[10,3],[5],[7,5,10,5,2],[]],[4,8,3,[],[0]],[[5],[5,9]],[3,[5,2],[1,4,2]]]]
[[[[1,7],3,0,[]]],[1,6,[5,[10,8,8],[]],[[6,10,2,5,7],6,[7,7,9],[6,4,8,8]],1],[5,[[10,10],3],[[],[2,10]],[1,1,[6,5,7],[10,5,2]],0]]
[[7,[[7],9,[4,1,3,8],0,4],[1,4,[0,7,6,1,1]]],[0,[2,[3,9,7],10,5],[0,[9,4,2,5,3]]],[0,7],[[7,9,9,3,1],10,[],0]]
[[2,[]],[4,0,5,7]]
[[[8,7],[4,[7,2,2,8],[8,3,9,9],1,0]],[[[7,4,7,3,10],[1,4,1],[0,10],10,[0]]]]
[[],[],[7]]
[[1,[[5,7,2],[10],0,[8],[10,9,0,10,8]]]]
[[],[2]]
[[[10,[9,9,6,3],1,9]],[10,[4,[1,9]],[],[8]],[[3,7,[10,2]],[[],[1,3],2]]]
[[8,6],[[5,0,10,[9]],[[1,5,8,4]],[[1,8,4,6],[4,7,6,2,0],[6,0],[6,3],[6,9,9,10]]]]
[[10],[8,3,2],[2,[1],[],6,[[6,8],[6,7,5],[9,2,9],7,7]]]
[[[3,[],[10,3,9],4,[5,9,10,3,8]],[2],0,[3],[[3,0],3]],[[7]],[4,[],[],[[9,3,5]],[[]]],[[10],[[6],7],[[1,4],1,[1,1,3],[5,0,4,5,6]],[[4],[7,0,4]],3],[[[],3,[]],8,[9],4]]
[[[7,[1],[8,4,3,7],3]],[[],[[5,5,3,8,7],[7,5,10,1,1]],8,8],[[2,[7,7,9],10],[4,[4,0,4,2],10,[1,10,9,6]],[[0],0,7],[0,8,[5,0,10,2,3],[7,3,6,5,5]]]]
[[9,[[8,5]],3,7,5],[[1,[],0,1]],[[[10,8],10,[1],[9,9,3,4]]],[8,[[5],2,3,[],[4,0,5]],0,5],[[4,[5,5,0,10],6,10],2,7,[],9]]
[[[[]],6,[[5,1],8,[4,10],4,[10,5,0,6,5]],1],[[4,[4],6],5,7,[[2],[10,1,4,5,4],2,6,[8]],4],[[],7,[[10],[1,5,9,3,9]]],[[1,[],2],[],0,7,[[7],[7]]],[[],[[9,0]],[0]]]
[[1,9,[],6],[[[9,0,4,3],[8,1,4]],0,[]],[1,[3,[2,4],[]],6,1,3]]
[[4,8,[1,[7,9,5,8,3]]],[[[6,5],[6,1,5,6,0],7,3],[]]]
[[7,0,7,[],[1,[7,1],10,[7,5,8,6]]],[],[[],4,[1,8],[[7],[5,8,0,4],1,[],9],[[],9,1,7]],[[[7],3,[10,2,2],9]]]
[[7,[[9,7,9,4,3],6,7],9],[1,0,[[1,2,0,7],[9],8,[10],[5,7]],[7]]]
[[[6,4,9],0,[],6]]
[[1,[[2,0,2,2],8,5],[],[[4,3],[10],[6],10]],[6,[7,1,[0,2,6,1],9,[0,5]],[[1,5,10,10],[7,8,3,10,3],[],2],7,[9,8,9]],[5,6,[[10,3,2,6,3]]]]
[[5],[[[4],[6,0,4,8]]],[[3,2],[10,[4],[1,8],8],5,1],[]]
[[10,[[],[4,3,6,2,10]],9],[[2,[5],2,[8,8],[8]],1,[5,4,10,0,[6,2,5]]],[[[3,7,9],[7,5,2,4]]],[10,[7],[3],8,8],[]]
[[4,5]]
[[1,[[6,5,2,7,0],4],[2,1],9],[],[[[4,3,1,0,1],9,1,6]],[[[6,7,0],1,5],5,7],[4,3]]
[[[1,[3],0],[[5],[10],2,[2,1,3,6]],6,[1,[7],1,[],7]],[[],[[10,4,7,7,5],4,[4,5],[3,6,10,9]],[[2,8,5,7],[8,1,0,9]],[[0,6,8],0,7,5,[4,1]],[3]]]
[[],[9,4,5,[]],[[],5]]
[[[9,0],10],[],[[10,10,[8,2,7],[4,7,3,10,2]],2,1],[[],7],[9,1,[],[[4,7,2],[4,0],0,2,7]]]
[[[10,[1],[0,3,5,7,9],1,[1,9,5,9]],[2,[10,4,6]],1],[2]]
[[[7,[9,6,6,7],1],6,10],[5,[7,[9,9,9],8]],[7],[9,8,[[0,5,1],[0,3,2,9]],6],[3,3]]
[[[[4,2]],[[9,10,9]]],[2,[8,[],7,[10],[]],3,2,6],[[0,8,[6,1,6]],1]]
[[[1,[5,9]],9,5],[[[],6,7,[],1],4,[[5,3],[10,2,7,3,10],[6,1,1],4,[]],2],[],[[7,[0,3,5]],[0]]]
[[3],[4],[[4,[10],7,[2],9],[1,[5,2,10,3],[9,6,1]]]]
[[],[[[6,9,7,10,8],4,6],[[5,5,9,8,3]],8,10],[6,9],[9]]
[[6,8,[10,9,8]]]
[[[0,3,[],[4,9,5,5],3]],[],[],[9],[[4,[5,3],[3,5,8]],6,[7,9]]]
[[3,[[]],[[3,4,2,10,0],10],[3],[[],9]],[1,2,4,9]]
[[[9,[0],8],0,3,10],[[4]],[9,7],[1],[[[0,3,0,0,7],1,[0,7],[4,3]]]]
[[[[8,6],2,6,4,[8,8]],[[]],[[],4,1],[10,[8,4,1,6,6],[4,9,7,6],9]],[6,10,8],[1,9,[]]]
[[10],[5,4,10,[[],3,4,5]],[[],3],[2,[4,[7,2]],6,10]]
[[6,9,10,[7]],[[3]]]
[[[[7,7,1]],0,1]]
[[[1,6,8],7,[[4,6],[8,9,5],[7,7,9],10],1,[7,[7,0,5],5,0,[3,7]]]]
[[[[8,1,7],[8,1],0,[0,6,8],[5]]],[5,[4,10],[1,[5,2,8,4,0]],[[7,10,6],3]],[],[8,[5,[5,4],[3]]]]
[[9],[[],[[5,4,6]],0],[6,6,6],[[[6],[4,6,5,5],1,0,[5,5,3]],4,4,[[6,8,7,5],[10,8,1,8,6]],[6,[10,0,2,8,9],[10,4],2,[10,5]]],[9,[],1,9]]
[[10,[3,[3,0,8],[10],[5,5,8,1]],[[3,0,5],[8],8,7]],[8],[[[],[7,6]],4],[10],[6,[]]]
[[[[5,0,2,9],5,[8,8,0]],[8,10,[8,9,4],[8,3,10,9],[6]],5],[[0,10,[10,8,3],8,6],6,[[9,9]],[3,[3,7,10],[8,2]],[[],9,3,[9,0,8]]],[[0],4,[7,9],[[2,10,5,7,5],[8,0,1,5],[6]]]]
[[],[10,[[7],8],4],[0],[[10,5,[0,9,9,4]],[]],[5]]
[[[0],3,7,7,[1,[0,4,8,9,7]]],[[3]],[7,[7],2,[3,[7,7,0],[6,10,4,7,9],[8,10,2,8,2],[9]]]]
[[5],[9,[6,[]]],[[5,2,[],9]],[[]]]
[[],[[[0,0,6,9],[6,3,2],5],[5,[2]],7],[[[5,2,4],[2,8],[4]],[5,[]]],[],[]]
[[[5,1,[6]],[[3,7],6,[6,6,8,3],[],10]],[],[[],1,[9,[7,2,10,2,9],7]],[6,[1,[0,10,10,1],2,7,[]],[[],1,5],[[7,3,1],[2,8,10,9],[9,5],4]],[[],9]]
[[[3,6,10],[[10,4,4],[9,0],10,[]],[9,[],[5,4,3,6,6]],6],[],[],[4,3,4,10],[[[10]],0]]
[[[[3,0],[6,2,8]],[[3],5,[],[10,8,7,6]],[9,6]],[]]
[[[],[6,7,6]],[1,[[],[8,1],[],[6]],9,[[5,0]],[2,9,8,5]],[5,[[10,4,4]],10,8]]
[[[[7,10,8],[8,6],6],2,[7,[2,8],1]],[[7,3,9,9,[6,4,8]]],[[4,1,[0]],4,7,[[10,2]]]]
[[[9,[10]],5,[[0,9,3,0,6],6,1,[0,10,2],4],4],[4,[[1,5,8,5]],3,6,[6,[8],[6,1,3],[2,2,0]]],[]]
[[],[4,1,[8,2,6],7]]
[[[9,[5,0,2,9],[5,9,3,7]],4]]
[[],[[3],2,3]]
[[5,5]]
[[],[7,0,10],[[]],[]]
[[],[],[[8,9,8,3,[4,5,2]],[[3,3,1],[],[6,9,1]],[4,9,[8,10,10,1],7],0,1],[]]
[[[9,6,5,10,1],8,9,[[7,10,3,9,5],10],2],[4,[],8]]
[[[[6,0,7,9,5]]],[[[4,4,3]],7],[[[7,0,2,9],[]],[5,[],9],4,[[8,8,9],[],2,[8,4,2,9,0],[4]],1],[8,6,6,[]],[[1,0],[],3,[6,[1,9],[6],[5,6]]]]
[[],[[[10,10],[]]],[]]
[[[2,[6,4,8],10,[6,6,3,9],4],[0,9,1,[]],[[],[3],9,5]],[[[6,7,8],[4,0],[9,5],[0],[3,10,3]],9],[],[],[[[4]],3,[[1,4,2,8],[5],5,[5,7,7,6],3]]]
[[10,7],[]]
[[7,2,2],[],[[],1,5,[5,9,[1],1,4]]]
[[4,5,[[9,10,0],6,7],3,6]]
[[],[5,[[4,10,4,5,2],[3,7,7,1,5],[7,4,1,5]],[[3,3],10,1,10]],[[],[[4,10]],9,10,10]]
[[],[5,[[1,4],[5,4,6,5,0],[10,10],0,[3]],[6,3,3,[0,3,5,0]],[[3,8,10,2],[4,4,2,2],4,[6],8]],[[[6,2],9],7,3],[10],[[],0,1]]
[[3,10,[],6],[[[]],6],[]]
[[[],6],[[],0],[[8],[[5,5],[],[8,4,7,6],[7]],[],1,[9,5]]]
[[],[7],[6,[3,2],0],[[[7,1,7],[6,5,1,8,8],[9,3,6,4,2]],[2,4]]]
[[9,[[7],0,[]],[9,[10]]],[10,0,[9,[1,1,5],[6,7]]],[1,9,2,[[5,3,1],9,0,5]]]
[[4]]
[[[[7,6],[10,7,5,2,0]],8,2,7],[3,[0],[7,0,[2,9],4]],[[3,8,2,4,[]],[[],[8,4,7],[2,9,8]],[[9,2]]],[5,[10],[[],[4,2,3],3,[1,7,5],[1]]]]
[[[[4,2,6],6,[9,6]]],[9,7,[[4,9,5],[10,1,8,7],6,3,1],[2,[4,6],1,8],1]]
[[[[8,1,1,6,7],[7,6,5],[6,8],[],[1,5,0,2]]]]
[[[[1,2,5,7],[],[7,2,3],10,8],4,10,4,10],[3,[6,[6,1],[3,7,0,7,0],10],[7],7]]
[[1],[[[1,9,4,8],[0],[10,5,8],[10,8]]],[3,7,5,[[1,2,9,1,7],[7,10,5,8,6],[0,3]],3]]
[[10,0]]
[[],[0,[1,[]],4],[8]]
[[],[[[10,3,2]],2,[[10,5,2,1]],[2,[]],[[1,9,4]]]]
[[[[4,9,2]],1,0,9,5],[[[0,5,10,1],[6,7],4,[1,6,4],[3,7]],[[0,10],2,5,9]]]
[[2,[10],7],[10,[[3,2],[7]],[7,[6,9,9,4],3,[7,1,2]]]]
[[[[9,6,4],8,[6,0,6,10],[7,1,0]]],[],[8,[9,[6,0,4,8],8,3],[],[1,[4,7,2,4]],0],[[[6,1,5],5],5,1],[4]]
[[[],[[],[]],[8,[5,2,7,7,8],[1,6,4,3,1],[0,10]]],[[[6,7,4]],3,[[],[6],[2,7,4,9]]]]
[[[[7,4,7]]]]
[[[[3,9,1,3,8],10,[2,6,8,2]],[],1],[1,2],[8,2],[]]
[[0,[6],[[6,9,8],5,4]],[[0],[],6,[6,[6,3,2]],3],[7,[[]]]]
[[9,10],[1,6],[]]
[[3],[6,1],[[[3,8]],2,[[],[3,9,8,0,2]],[]],[[1,3],4,[6]],[6]]
[[2,[3,5,1,5,[1,8,2]]],[5,5,[[8,4,8],10,[10,4],6]],[[[10,9],[3,9,8,2,8],[]],8]]
[[[5],6,[2],9],[10]]
[[2,[0,[6],6,3,[8,4,10]],[[9],7,[3,10,1],[10,5],9],4]]
[[[[9,10,5,6]]],[[2,9],[10,8]]]
[[3,[[6,1,0,2],[9],2,3],[5,[6,3,0,10],1]],[]]
[[10,9,[],[]],[[6]],[0],[10,[10,6,5,[1]],[[3,10,0,8,1]]]]
[[7,[[4],2,5],2],[[1,3,[7,4,4,9,5]]],[3,2,[[],1,2,[4],[6,4]],[]]]
[[],[[[]],3,[7,2,[]]]]
[[1,[[6,9]],5,[[9,5,5,5],9,8,8],[3,2,5,[4,0,4],3]],[4,7],[[[4,2,7,3],[5,1],[10,4]],[[2,9,2],[7,8,1],[10,4,2,3,6],[],5],[10,9,[]]],[9]]
[[[5,10,[6,5,9,3,3],8]],[],[[7,[4],1,0,[9,4,8]],[[10,1],2,3,6],8,3]]
[[8,4,3,8,[1,0]],[5,[7,[],7]],[10,[[6,2,4],[7,3,7,5],[],[],1],6,2],[[],[[0,9,6],[],8]],[9,[],10]]
[[[[10,8,5,0]],[]],[7],[[1,[2],[8,0,0]],[[2],[],[2,1,1,0,8]],3,[[10,4]],7],[10,[1,[4,5,7],10,5,[8,5,2,10]],1,9]]
[[1],[0,1,[2,7],[[10],1,[]],[[3,3,4,2,5],4,[],[6,3,1,10],3]],[[3,[9,9,9,1],[8,9,0],0],3,3],[10],[[9,[9,1,6,7],7]]]
[[1,4,[],5],[4,[2,8,6,[3,5,6,4]],3,4,[[],2,[]]],[[[7,1,0,1],[6,10,9,8,3]],[[10,10],6,[]],0],[]]
[[2,10]]
[[[0],0,[[1,0],[5,5,9]]]]
[[5,[[3],10,[9,9],[6,4],[]],[5,3,9,[5,0,10,4],9]],[[[0,1,1,8,5]]],[[],[[2,9,7,2],3,1,[6,3]],8,[]],[],[9,9,[[4,0,4],[],3,1]]]
[[],[8,9],[[],9,3,5],[[9,1,[1,4]],[[2],[6,8],[4]],[[],4,[]],8,4]]
[[0],[4]]
[[[4,7,1,6]],[[10,3,3,3]]]
[[[[2,9,9,7],1],[1,3,[1,9,8,9,8],10],3,3,5]]
[[[1,6,[3,7,3,0,4],10,[5,2,7]],[[6,5,10,8,6],[8,3,10,5,10],[9,3,5],2,4],10,[7,6]],[1],[[[4,9,3],6,2,[5,4,4,1],2],[[0,3]],9]]
[[8,[],2]]
[[3,[5,2,[5,1],[8,4,4],10],6,[[1,4],[]],8],[6,10],[[1,4,[5],2,0],4,[[],3],[5,6],2]]
[[1,9],[]]
[[2,[0,3,8,2]]]
[[[6,5,7],[2,6]],[10,7,[6,9,6,[3,8,2],[]],1,10],[[[5,2,6,5],4,[]],[6,0,6],1,[]],[5],[[6,3,[7,7,3,2,0]],[[],[7,1,3,5]],[]]]
[[4,[[3,6,9,8,4],0,8,[10,0]],6,0],[3,1,[[7]],[6,8,8,1,4],2],[8,[6,[1],4,0,[8,3,8]],[3]],[[[7,5,3,10]],6,2],[2,[0,[]],5,[4,7]]]
[[5,0,1,[9,[],[1,10,6,6],[]]],[],[[1],8],[[2,[1,9,1,3]]],[[[],[],7,9,[]]]]
[[],[],[4,2,[[],[3],[3,2,8],0],[[10],[0,7,5,0],[10,8],0,[]],[[],6,2]],[[[5,8,1],[2]],[8],6,[1]]]
[6,0,1,5,5]
[6,0,1,5]
[[[4],[],4],[2,[[],[0,5],7,[4,4]],[[9,6],5]],[],[[],2,[],7]]
[[[7,[9,8,8,3]],[],[],6],[9,[[2,0],[7,0],2],5,[[]],[[3,3,6],6,[1,6,1],[10,4]]],[8,[9],4],[[[],[10,0,5],8]]]
[[[[9,10,2],3,5,[9,8,8,9],4]],[6,[]],[[],[4,10,2,6,[2]],6],[4,6,5,[[],[],3,9,[4,0,2]],5]]
[[5,[[],[1,4,2,4],1]],[2],[7,[8,4,4]]]
[1,9,4,8]
[1,9,4,8,5]
[[[[],8,[7,9],4],10,[4,[10,8,4,0]],[3,[10,7],1,[]],[[8,6,8,7,8],2,9]],[]]
[[6,0],[10,10,6,[2,[],[8,1,6,4]]]]
[[8,6],[[[]]]]
[[5,6]]
[[],[],[[7],[8],[0,8,0,5],9,2],[1,3,3,[7,8],[4,0,[6,3,9,1],[3,8,4,2,5],[9,5]]],[10,[[0,9,0],[7,9]],9,3]]
[[],[[7,7,[2]],[[6,5,10,7],[8,4,9,0,4],6],[2,9,[4,8],10,5],[2,[7,10,0,1],[3,7]]],[[[5,4,0],[6,5],7,0,[2,6,5]],4,1,[4,10,1,2]],[[3]]]
[[9,[],3],[10,[4,9,10,0]],[[],5,[[8,0,7,9],6,3],[[10,4],[8,6,0,7],3,2]],[2],[[5]]]
[[[[4],9,[0,7,4,10]],8,[5,8,6,0]],[6],[5,[[],[7,0,5,5],0,[]]],[1,[1,[7,1,10,0,8],2],[2,[9,2,2,8],1,10,[6,9,3]]]]
[[[],4,[10],[5,[1,0,9],2]],[[6,[4],2,4,10],6,[5],[2,7,[7,6,3,4]]],[[7,1,[5]],10,[1,[0],[],[8,9,9,7],7]],[6,[8],1,3,10],[10,[9]]]
[[1,1,0,0],[1,[[3,10,6,9,10]],[[3,0,6,4,9],0,2]]]
[[10,[7],5,[],6],[[7,[3,10,9,1],[8],[],[1,0]],[5,8]],[7,[[4,4,0]],10,[3,[9,3,5,2,0],9]]]
[[5,[[4,8]],9,[0,[7,7,8,0,3],4,10],[10,[5,1,7,7,10]]],[],[6,5],[[],7,1,[[],[0,8,1],10],[]],[[],[],[3,10,[2,9,10,4,10],4],10,[10,[10,10,6,8,5],[5],6]]]
[[[],2,[10,[6,3,10,7],[]],[]],[],[[4,7,[],7,[]],[[1],10,[8,0],10,2],[[8,0,3,3,4],[7,2,3],[3,8,6,9],9],[],[6,8,0,[7]]],[10],[[[8,0,4,6],3,[]],0,6,[[6],5,7,9],[[4,0,7,5]]]]
[[1,[[0],[],[],5],8,6],[0,[2,6,2,[9],6],2],[[[0,4,5,5,4]],[4,5,1,6],3]]
[[[[5,4,0,9,10],[0,0,7,8,5],[4,6,7],8,5],[[5,2,0,7,3],5,[],[0,0]],[1,3,1,[2],[]],8]]
[[[1,[9,4,4],[8,1,5]],[[5,2],4,10,3,10]],[[[9,6,8]]],[[4,[6,0,2,9,8],[],[10,10,9,2,2],0]],[10,0,[]]]
[[],[[7,[10,9,10],4],[2,2,[1,0]]],[[2,[3,8,5,9,3]],[[3,2,9],[],5,8],[],[[10,2],0,[]],[[10,6,0],5]],[3,[],[],[2,5,[4,8,1,7],4],[]],[8,1,[[3,4,6,7,1],7]]]
[[1],[[[4,7,9,10],3,[5,9,7,9,10]]]]
[[1,10,[7,[],[7,6,3],10,9],[[0,10,0]],[4,6,[3]]],[[[6,2,6,3],10,[3,0,7,4]],5,10,6,[[5],6,[],9,[8,2,10,0]]],[],[[[0,8],10],8,[[1,8,1,3,6],2,[6],[7,0]],1]]
[[[3],3,[8,7,[10,8,4,3,6],2],[6,2],5]]
[[[[1,0,4,3],[9],[1],2]],[[8,9,0],[],10,8,[[5,5,6,5],6]],[[[9],0,10],1,[2,8]],[9]]
[[[2],7,0,1,5],[[[1,6,4,3,4],6,1],[],5,[],[[7,4],[4,1,8,7,0],[],6]],[0,[0,[9],[9]],[10,1,7,[]],2,[[6,5,9,1],[3],5,[5],4]],[8,10,[[10,5,4],0],[5,[10],10,[1]]],[]]
[[],[2],[1],[9,[[1,2,7]]],[[[1,1],[2],10,[7,1,0]],6]]
[[4,[[9,8]],[[9,3],1,[6]]],[[[4,2,5],[],[],2,6],3],[[[1,0,5,6],[2,6,10,5,9],[1,4,3,0,2],[10,2,9]],[5,2,7,[10,10,9,4,3]],[[3,5,8,9],[10,1,3,10],[],[2,8,1,8]],3,[]],[0,[],[[2,4],[8],[],[5,7,1,1]]],[[[],9,1,7],7]]
[[4,0,[1,10,[],0,[]],8,0],[],[],[4]]
[[4,[9],2],[9],[3]]
[[[[6,0,4,2,0],9,[7,8],8]],[],[[2,7],1,4]]
[[],[[]],[],[[[9,7],4,[0],[3,10,10,8,4]],6,5]]
[[[7]],[],[],[[],[7]],[7,[3,6,3],1]]
[[[8],[7],[3],[[3,2,4,9]],4],[[5,0,[3],[6]]],[[[9,9],[10,1,0,6,3],2]],[0,[2,8,[4,4],2],2]]
[[],[[[4,3,0,2],[2,4,10,5,3],[]],[[5,9],7,[4,6]],[[6,6],[6,9,2,4],[9,8,9],8]],[[],2,8,8]]
[[[5,9,10],[4,[10]],[[],[9],[]],[4,2,6],2],[[4,[7,3,1,9,3],[3,1,6,5],8]]]
[[[[4,0],10,3],[[6],[],10],10,6],[8,7]]
[[],[],[10,2,0],[[[3,8,7],[2,0]]],[3,5,5,1]]
[[[[8,7],4,6,[10,7,9],[1,2]],3,[[5,5,5],4,[0],0]],[6,[[2,0,2,10,2],9],[8,0,[5,5,1,7,6],[2,5,2],[]]],[[[4,5,5],2,5,[4,8]]],[10,4],[[3,[],1,3],[],[3,[9,7,0,1]]]]
[[[[9,9],9,6,8],3,[[],[],[10,8,6,7,6]],2],[[[0,5],4,7,[8,7,10],2],[[9,1],9,[4,9],6],2,5,[4,[7,6,6,4],3,8]],[[],[3,[7,7],1],10]]
[[9,[0,3,[0,6,9]],[[7,1],[4,4,3,1,9],10],1,3]]
[[8,7,8],[8,4,[]],[[[1],[4,9],[3]],6,8,[4,[6,3],[7],[1,0,10,7],10]],[2,2,0]]
[[2,10,2],[],[[[2,6,8,7],2],[7,[]]],[7,[[4]],9],[1,[3,[10,2]]]]
[[[],[]],[[3,5],[],10],[]]
[[2,6,6]]
[[8],[[4],[0,3,[]],[[8,6,0]],[10,10,8,1]],[[0,7],2,[0,10,[7,7,0,7,5],2],7],[[[2,5,7],6,4,10,2],7],[9]]
[[[9,[7,3],[9,7],1]],[[7,[6,4],1],[0],7,[]],[5,7,[[9,10,10],[10,2]]]]
[[8,[]],[[],[7,10,5,3,[5,8]],[],[[],4,2,8,[2,7,5,7,0]],[1,[9]]],[4,1,2,4,5]]
[[3,4,[]],[],[3,8,5,[4]]]
[[[5]],[],[],[[[3]],[[3,3,2,9,10],[0,6,5,7],9,2]]]
[[],[6,[10]],[[5,8,[5,7,4]],5,5],[1,[4,4,[],3,[4,1]],[[5,1,2,7],[10,6],2],[[7],0,0,[7],[1,4]],[8]]]
[[[[6,10,2],[],6,[5,1,1,1,1]],[8,2,[6,7],10,5],3],[6,[5,[9,4,3]]],[[[2,6,10],[0],9,9,[3]],9,5],[9,[9],[[4,4,10],10,6,[],[0,7]],[4,[8,1,9,5],[4]],[[0,3,7,7],[0,9,10,10]]]]
[[[],5,[3,[],9,[8,10]],2,6],[1,[6,[],6,[10,7,7,6],[3,7]],5],[7,10,[[8],[9,6],[],3,5],[[],4,2,8]],[[8,[]]],[8]]
[[9,4],[10,5],[[6,10,[0,1,1],0],7,4],[2,3,[7,8,1,1],6]]
[[],[[1,[2,1],5,[],9],6,[9,4,8],[[5,1,7],[10,1,8],0]],[8,1,[[],2,[2,8]]],[[3,[2,3,0],8,6,[]],[8,4,[8],[10,7,2,2,0]],9,1,[1,[0,8,7,1],2]],[[9,5],[[1,2],[],10,7],2]]
[[[10],6,7,4],[],[7,[0,9],[1,10,[0,10]],[[3,10],5,[9,9,8]]]]
[[[5,[0,8,0]],[[6,3,2,3,5],[8,4]],1],[[[6,6,6,2],1,[2,2],2],9,6,2],[]]
[[[],[],[[4,5],0],[10,6,7]],[[8,[9,8]]],[[[],[],3,7],[],0]]
[[],[7,4],[[5],5],[[],1,10,[0,[5,0,1,10,6],[8],1,[4]],0],[0]]
[[],[1,0,10],[]]
[[3,2,[[7,9,4,8,2],2,[1,0,9,6],10,[3,0]]],[[9,6],[[]],1,[[],5,[5,4]],[2]],[],[8,[[6],2]],[[]]]
[[0,[1],[],[[2]]],[[5,[1,0]],[[],2]],[4,[10,2,5],[[6,7,2,10,1],1,0,1]],[]]
[[0,[],[[5,3,5,3,0],[],[3,8,0,0,1],[2]]],[]]
[[[7,2],6,[8],[],[]]]
[[[10],0,0,[[0,9]]],[[0,4],[[2,9,1,3]],9],[2,[[]],[7,[0,8],8]],[6,[[6,9],10,[],[4,2],[0]]]]
[[8,[0,9]],[[2,6,8,[5],[8,1,1,9,4]],1,4],[[1,5],2]]
[[[10,[],9,7,6]],[1],[],[[8],10,[9],[]]]
[[[[9,7,7,7,0],[0,3,9,9,2],5],8,0,0],[],[[3,2,2,[2]],[2,[]],7],[[9,[7,8,9,9,10],[8,10]],6,10,[[]]],[]]
+104 -1
View File
@@ -1 +1,104 @@
# Day 13 Puzzle Text.
<article class="day-desc"><h2>--- Day 13: Distress Signal ---</h2><p>You climb the hill and again try contacting the Elves. However, you instead receive a signal you weren't expecting: a <em>distress signal</em>.</p>
<p>Your handheld device must still not be working properly; the packets from the distress signal got decoded <em>out of order</em>. You'll need to re-order the list of received packets (your puzzle input) to decode the message.</p>
<p>Your list consists of pairs of packets; pairs are separated by a blank line. You need to identify <em>how many pairs of packets are in the right order</em>.</p>
<p>For example:</p>
<pre><code>[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]
</code></pre>
<p><span title="The snailfish called. They want their distress signal back.">Packet data consists of lists and integers.</span> Each list starts with <code>[</code>, ends with <code>]</code>, 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.</p>
<p>When comparing two values, the first value is called <em>left</em> and the second value is called <em>right</em>. Then:</p>
<ul>
<li>If <em>both values are integers</em>, the <em>lower integer</em> 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.</li>
<li>If <em>both values are lists</em>, 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.</li>
<li>If <em>exactly one value is an integer</em>, convert the integer to a list which contains that integer as its only value, then retry the comparison. For example, if comparing <code>[0,0,0]</code> and <code>2</code>, convert the right value to <code>[2]</code> (a list containing <code>2</code>); the result is then found by instead comparing <code>[0,0,0]</code> and <code>[2]</code>.</li>
</ul>
<p>Using these rules, you can determine which of the pairs in the example are in the right order:</p>
<pre><code>== 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 <em>in the right order</em>
== 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 <em>in the right order</em>
== 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 <em>not</em> 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 <em>in the right order</em>
== 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 <em>not</em> in the right order
== Pair 6 ==
- Compare [] vs [3]
- Left side ran out of items, so inputs are <em>in the right order</em>
== Pair 7 ==
- Compare [[[]]] vs [[]]
- Compare [[]] vs []
- Right side ran out of items, so inputs are <em>not</em> 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 <em>not</em> in the right order
</code></pre>
<p>What are the indices of the pairs that are already <em>in the right order</em>? (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 <code><em>13</em></code>.</p>
<p>Determine which pairs of packets are already in the right order. <em>What is the sum of the indices of those pairs?</em></p>
+168 -1
View File
@@ -1 +1,168 @@
Paste any inputs into this file. 519,81 -> 524,81
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
540,132 -> 540,133 -> 552,133 -> 552,132
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
547,139 -> 552,139
558,142 -> 563,142
501,24 -> 505,24
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
551,142 -> 556,142
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
507,20 -> 511,20
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
545,148 -> 550,148
522,104 -> 526,104
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
517,90 -> 522,90
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
538,148 -> 543,148
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
548,145 -> 553,145
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
528,108 -> 532,108
562,145 -> 567,145
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
495,24 -> 499,24
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
541,116 -> 541,117 -> 549,117 -> 549,116
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
501,20 -> 505,20
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
554,139 -> 559,139
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
541,116 -> 541,117 -> 549,117 -> 549,116
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
552,148 -> 557,148
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
523,84 -> 528,84
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
540,132 -> 540,133 -> 552,133 -> 552,132
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
540,132 -> 540,133 -> 552,133 -> 552,132
524,90 -> 529,90
544,142 -> 549,142
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
559,148 -> 564,148
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
507,24 -> 511,24
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
498,22 -> 502,22
525,106 -> 529,106
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
510,90 -> 515,90
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
494,14 -> 494,15 -> 505,15 -> 505,14
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
555,145 -> 560,145
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
494,14 -> 494,15 -> 505,15 -> 505,14
522,108 -> 526,108
494,14 -> 494,15 -> 505,15 -> 505,14
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
504,18 -> 508,18
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
519,106 -> 523,106
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
510,22 -> 514,22
513,24 -> 517,24
495,50 -> 495,40 -> 495,50 -> 497,50 -> 497,43 -> 497,50 -> 499,50 -> 499,43 -> 499,50 -> 501,50 -> 501,41 -> 501,50
499,53 -> 499,57 -> 491,57 -> 491,63 -> 513,63 -> 513,57 -> 505,57 -> 505,53
527,87 -> 532,87
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
514,93 -> 514,97 -> 506,97 -> 506,101 -> 523,101 -> 523,97 -> 518,97 -> 518,93
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
531,90 -> 536,90
504,22 -> 508,22
520,87 -> 525,87
530,130 -> 530,123 -> 530,130 -> 532,130 -> 532,126 -> 532,130 -> 534,130 -> 534,128 -> 534,130 -> 536,130 -> 536,123 -> 536,130 -> 538,130 -> 538,124 -> 538,130 -> 540,130 -> 540,126 -> 540,130 -> 542,130 -> 542,122 -> 542,130 -> 544,130 -> 544,127 -> 544,130 -> 546,130 -> 546,125 -> 546,130 -> 548,130 -> 548,125 -> 548,130
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
550,136 -> 555,136
528,112 -> 542,112
516,84 -> 521,84
516,108 -> 520,108
541,145 -> 546,145
541,116 -> 541,117 -> 549,117 -> 549,116
534,161 -> 534,157 -> 534,161 -> 536,161 -> 536,154 -> 536,161 -> 538,161 -> 538,156 -> 538,161 -> 540,161 -> 540,153 -> 540,161 -> 542,161 -> 542,151 -> 542,161 -> 544,161 -> 544,160 -> 544,161 -> 546,161 -> 546,156 -> 546,161 -> 548,161 -> 548,159 -> 548,161 -> 550,161 -> 550,159 -> 550,161 -> 552,161 -> 552,159 -> 552,161
551,164 -> 551,168 -> 546,168 -> 546,171 -> 556,171 -> 556,168 -> 555,168 -> 555,164
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
513,87 -> 518,87
512,66 -> 512,70 -> 505,70 -> 505,78 -> 521,78 -> 521,70 -> 516,70 -> 516,66
486,37 -> 486,34 -> 486,37 -> 488,37 -> 488,34 -> 488,37 -> 490,37 -> 490,28 -> 490,37 -> 492,37 -> 492,28 -> 492,37 -> 494,37 -> 494,30 -> 494,37 -> 496,37 -> 496,36 -> 496,37 -> 498,37 -> 498,36 -> 498,37
566,148 -> 571,148
+105 -1
View File
@@ -1 +1,105 @@
# Day 14 Puzzle Text.
<article class="day-desc"><h2>--- Day 14: Regolith Reservoir ---</h2><p>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 <em>behind</em> the waterfall.</p>
<p>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.</p>
<p>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!</p>
<p>Fortunately, your <a href="/2018/day/17">familiarity</a> 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 <em>air</em> with structures made of <em>rock</em>.</p>
<p>Your scan traces the path of each solid rock structure and reports the <code>x,y</code> coordinates that form the shape of the path, where <code>x</code> represents distance to the right and <code>y</code> 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:</p>
<pre><code>498,4 -&gt; 498,6 -&gt; 496,6
503,4 -&gt; 502,4 -&gt; 502,9 -&gt; 494,9
</code></pre>
<p>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 <code>498,4</code> through <code>498,6</code> and another line of rock from <code>498,6</code> through <code>496,6</code>.)</p>
<p>The sand is pouring into the cave from point <code>500,0</code>.</p>
<p>Drawing rock as <code>#</code>, air as <code>.</code>, and the source of the sand as <code>+</code>, this becomes:</p>
<pre><code>
4 5 5
9 0 0
4 0 3
0 ......+...
1 ..........
2 ..........
3 ..........
4 ....#...##
5 ....#...#.
6 ..###...#.
7 ........#.
8 ........#.
9 #########.
</code></pre>
<p>Sand is produced <em>one unit at a time</em>, and the next unit of sand is not produced until the previous unit of sand <em>comes to rest</em>. A unit of sand is large enough to fill one tile of air in your scan.</p>
<p>A unit of sand always falls <em>down one step</em> if possible. If the tile immediately below is blocked (by rock or sand), the unit of sand attempts to instead move diagonally <em>one step down and to the left</em>. If that tile is blocked, the unit of sand attempts to instead move diagonally <em>one step down and to the right</em>. 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 <em>comes to rest</em> and no longer moves, at which point the next unit of sand is created back at the source.</p>
<p>So, drawing sand that has come to rest as <code>o</code>, the first unit of sand simply falls straight down and then stops:</p>
<pre><code>......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
........#.
......<em>o</em>.#.
#########.
</code></pre>
<p>The second unit of sand then falls straight down, lands on the first one, and then comes to rest to its left:</p>
<pre><code>......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
........#.
.....oo.#.
#########.
</code></pre>
<p>After a total of five units of sand have come to rest, they form this pattern:</p>
<pre><code>......+...
..........
..........
..........
....#...##
....#...#.
..###...#.
......o.#.
....oooo#.
#########.
</code></pre>
<p>After a total of 22 units of sand:</p>
<pre><code>......+...
..........
......o...
.....ooo..
....#ooo##
....#ooo#.
..###ooo#.
....oooo#.
...ooooo#.
#########.
</code></pre>
<p>Finally, only two more units of sand can possibly come to rest:</p>
<pre><code>......+...
..........
......o...
.....ooo..
....#ooo##
...<em>o</em>#ooo#.
..###ooo#.
....oooo#.
.<em>o</em>.ooooo#.
#########.
</code></pre>
<p>Once all <code><em>24</em></code> 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 <code>~</code>:</p>
<pre><code>.......+...
.......~...
......~o...
.....~ooo..
....~#ooo##
...~o#ooo#.
..~###ooo#.
..~..oooo#.
.~o.ooooo#.
~#########.
~..........
~..........
~..........
</code></pre>
<p>Using your scan, simulate the falling sand. <em>How many units of sand come to rest before sand starts flowing into the abyss below?</em></p>
+32 -1
View File
@@ -1 +1,32 @@
Paste any inputs into this file. Sensor at x=2885528, y=2847539: closest beacon is at x=2966570, y=2470834
Sensor at x=2224704, y=1992385: closest beacon is at x=2018927, y=2000000
Sensor at x=3829144, y=1633329: closest beacon is at x=2966570, y=2470834
Sensor at x=43913, y=426799: closest beacon is at x=152363, y=369618
Sensor at x=2257417, y=2118161: closest beacon is at x=2386559, y=2090397
Sensor at x=8318, y=3994839: closest beacon is at x=-266803, y=2440278
Sensor at x=69961, y=586273: closest beacon is at x=152363, y=369618
Sensor at x=3931562, y=3361721: closest beacon is at x=3580400, y=3200980
Sensor at x=476279, y=3079924: closest beacon is at x=-266803, y=2440278
Sensor at x=2719185, y=2361091: closest beacon is at x=2966570, y=2470834
Sensor at x=2533382, y=3320911: closest beacon is at x=2260632, y=3415930
Sensor at x=3112735, y=3334946: closest beacon is at x=3580400, y=3200980
Sensor at x=1842258, y=3998928: closest beacon is at x=2260632, y=3415930
Sensor at x=3712771, y=3760832: closest beacon is at x=3580400, y=3200980
Sensor at x=1500246, y=2684955: closest beacon is at x=2018927, y=2000000
Sensor at x=3589321, y=142859: closest beacon is at x=4547643, y=-589891
Sensor at x=1754684, y=2330721: closest beacon is at x=2018927, y=2000000
Sensor at x=2476631, y=3679883: closest beacon is at x=2260632, y=3415930
Sensor at x=27333, y=274008: closest beacon is at x=152363, y=369618
Sensor at x=158732, y=2405833: closest beacon is at x=-266803, y=2440278
Sensor at x=2955669, y=3976939: closest beacon is at x=3035522, y=4959118
Sensor at x=1744196, y=13645: closest beacon is at x=152363, y=369618
Sensor at x=981165, y=1363480: closest beacon is at x=2018927, y=2000000
Sensor at x=2612279, y=2151377: closest beacon is at x=2386559, y=2090397
Sensor at x=3897, y=2076376: closest beacon is at x=-266803, y=2440278
Sensor at x=2108479, y=1928318: closest beacon is at x=2018927, y=2000000
Sensor at x=1913043, y=3017841: closest beacon is at x=2260632, y=3415930
Sensor at x=2446778, y=785075: closest beacon is at x=2386559, y=2090397
Sensor at x=2385258, y=2774943: closest beacon is at x=2386559, y=2090397
Sensor at x=3337656, y=2916144: closest beacon is at x=3580400, y=3200980
Sensor at x=380595, y=66906: closest beacon is at x=152363, y=369618
Sensor at x=1593628, y=3408455: closest beacon is at x=2260632, y=3415930
+88 -1
View File
@@ -1 +1,88 @@
# Day 15 Puzzle Text.
<article class="day-desc"><h2>--- Day 15: Beacon Exclusion Zone ---</h2><p>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 <em>sensors</em> that you imagine were originally built to locate lost Elves.</p>
<p>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.</p>
<p>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 <em>beacon</em>. Sensors and beacons always exist at integer coordinates. Each sensor knows its own position and can <em>determine the position of a beacon precisely</em>; however, sensors can only lock on to the one beacon <em>closest to the sensor</em> as measured by the <a href="https://en.wikipedia.org/wiki/Taxicab_geometry" target="_blank">Manhattan distance</a>. (There is never a tie where two beacons are the same distance to a sensor.)</p>
<p>It doesn't take long for the sensors to report back their positions and closest beacons (your puzzle input). For example:</p>
<pre><code>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
</code></pre>
<p>So, consider the sensor at <code>2,18</code>; the closest beacon to it is at <code>-2,15</code>. For the sensor at <code>9,16</code>, the closest beacon to it is at <code>10,16</code>.</p>
<p>Drawing sensors as <code>S</code> and beacons as <code>B</code>, the above arrangement of sensors and beacons looks like this:</p>
<pre><code> 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....
</code></pre>
<p>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 <code>8,7</code>:</p>
<pre><code> 1 1 2 2
0 5 0 5 0 5
-2 ..........#.................
-1 .........###................
0 ....S...#####...............
1 .......#######........S.....
2 ......#########S............
3 .....###########SB..........
4 ....#############...........
5 ...###############..........
6 ..#################.........
7 .#########<em>S</em>#######S#........
8 ..#################.........
9 ...###############..........
10 ....<em>B</em>############...........
11 ..S..###########............
12 ......#########.............
13 .......#######..............
14 ........#####.S.......S.....
15 B........###................
16 ..........#SB...............
17 ................S..........B
18 ....S.......................
19 ............................
20 ............S......S........
21 ............................
22 .......................B....
</code></pre>
<p>This sensor's closest beacon is at <code>2,10</code>, and so you know there are no beacons that close or closer (in any positions marked <code>#</code>).</p>
<p>None of the detected beacons seem to be producing the distress signal, so you'll need to <span title="&quot;When you have eliminated all which is impossible, then whatever remains, however improbable, must be where the missing beacon is.&quot; - Sherlock Holmes">work out</span> where the distress beacon is by working out where it <em>isn't</em>. For now, keep things simple by counting the positions where a beacon cannot possibly be along just a single row.</p>
<p>So, suppose you have an arrangement of beacons and sensors like in the example above and, just in the row where <code>y=10</code>, 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:</p>
<pre><code> 1 1 2 2
0 5 0 5 0 5
9 ...#########################...
<em>10 ..####B######################..</em>
11 .###S#############.###########.
</code></pre>
<p>In this example, in the row where <code>y=10</code>, there are <code><em>26</em></code> positions where a beacon cannot be present.</p>
<p>Consult the report from the sensors you just deployed. <em>In the row where <code>y=2000000</code>, how many positions cannot contain a beacon?</em></p>
+57 -1
View File
@@ -1 +1,57 @@
Paste any inputs into this file. Valve RU has flow rate=0; tunnels lead to valves YH, ID
Valve QK has flow rate=24; tunnels lead to valves PQ, PP
Valve RP has flow rate=11; tunnels lead to valves RM, BA, RI, EM
Valve BX has flow rate=0; tunnels lead to valves ZX, VK
Valve JL has flow rate=0; tunnels lead to valves ID, LC
Valve DC has flow rate=25; tunnel leads to valve ST
Valve HX has flow rate=0; tunnels lead to valves DH, FE
Valve KJ has flow rate=0; tunnels lead to valves ZK, XN
Valve EM has flow rate=0; tunnels lead to valves AW, RP
Valve XN has flow rate=7; tunnels lead to valves LH, KJ, KU, AO
Valve DH has flow rate=9; tunnels lead to valves SY, CC, QL, LH, HX
Valve LH has flow rate=0; tunnels lead to valves XN, DH
Valve PP has flow rate=0; tunnels lead to valves QK, TA
Valve AO has flow rate=0; tunnels lead to valves AA, XN
Valve SY has flow rate=0; tunnels lead to valves DH, AA
Valve MZ has flow rate=0; tunnels lead to valves JT, PF
Valve AA has flow rate=0; tunnels lead to valves JN, UN, WG, SY, AO
Valve RM has flow rate=0; tunnels lead to valves XL, RP
Valve BA has flow rate=0; tunnels lead to valves RP, YP
Valve AD has flow rate=12; tunnels lead to valves LK, ZX, AW
Valve ZN has flow rate=0; tunnels lead to valves EQ, HL
Valve EX has flow rate=18; tunnel leads to valve RB
Valve CR has flow rate=0; tunnels lead to valves TA, ST
Valve WG has flow rate=0; tunnels lead to valves AA, TA
Valve UN has flow rate=0; tunnels lead to valves WK, AA
Valve VE has flow rate=0; tunnels lead to valves JA, KW
Valve JA has flow rate=19; tunnels lead to valves PQ, VE
Valve AW has flow rate=0; tunnels lead to valves AD, EM
Valve XL has flow rate=0; tunnels lead to valves RM, PF
Valve OD has flow rate=0; tunnels lead to valves VK, RI
Valve FE has flow rate=0; tunnels lead to valves JT, HX
Valve PQ has flow rate=0; tunnels lead to valves JA, QK
Valve RB has flow rate=0; tunnels lead to valves CC, EX
Valve JT has flow rate=3; tunnels lead to valves RF, MZ, ZK, FE, DD
Valve YP has flow rate=0; tunnels lead to valves ID, BA
Valve ID has flow rate=14; tunnels lead to valves JL, RU, YP
Valve YH has flow rate=0; tunnels lead to valves RU, VK
Valve TA has flow rate=21; tunnels lead to valves WG, KU, PP, RF, CR
Valve LK has flow rate=0; tunnels lead to valves PF, AD
Valve DD has flow rate=0; tunnels lead to valves JN, JT
Valve HL has flow rate=0; tunnels lead to valves ZN, DW
Valve VK has flow rate=22; tunnels lead to valves OD, KW, BX, YH
Valve RF has flow rate=0; tunnels lead to valves JT, TA
Valve CC has flow rate=0; tunnels lead to valves RB, DH
Valve KW has flow rate=0; tunnels lead to valves VE, VK
Valve PF has flow rate=10; tunnels lead to valves WK, MZ, QL, XL, LK
Valve ZX has flow rate=0; tunnels lead to valves AD, BX
Valve JN has flow rate=0; tunnels lead to valves DD, AA
Valve ST has flow rate=0; tunnels lead to valves CR, DC
Valve WK has flow rate=0; tunnels lead to valves PF, UN
Valve DW has flow rate=13; tunnels lead to valves LC, HL
Valve ZK has flow rate=0; tunnels lead to valves KJ, JT
Valve QL has flow rate=0; tunnels lead to valves DH, PF
Valve RI has flow rate=0; tunnels lead to valves OD, RP
Valve EQ has flow rate=23; tunnel leads to valve ZN
Valve LC has flow rate=0; tunnels lead to valves JL, DW
Valve KU has flow rate=0; tunnels lead to valves XN, TA
+136 -1
View File
@@ -1 +1,136 @@
# Day 16 Puzzle Text.
<article class="day-desc"><h2>--- Day 16: Proboscidea Volcanium ---</h2><p>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.</p>
<p>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!</p>
<p>You need to get the elephants out of here, quickly. Your device estimates that you have <em>30 minutes</em> before the volcano erupts, so you don't have time to go back out the way you came in.</p>
<p>You scan the cave for other options and discover a network of pipes and pressure-release <em>valves</em>. 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 <em>flow rate</em> if it were opened (in pressure per minute) and the tunnels you could use to move between the valves.</p>
<p>There's even a valve in the room you and the elephants are currently standing in labeled <code>AA</code>. 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?</p>
<p>For example, suppose you had the following scan output:</p>
<pre><code>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
</code></pre>
<p>All of the valves begin <em>closed</em>. You start at valve <code>AA</code>, but it must be damaged or <span title="Wait, sir! The valve, sir! it appears to be... jammed!">jammed</span> or something: its flow rate is <code>0</code>, so there's no point in opening it. However, you could spend one minute moving to valve <code>BB</code> and another minute opening it; doing so would release pressure during the remaining <em>28 minutes</em> at a flow rate of <code>13</code>, a total eventual pressure release of <code>28 * 13 = <em>364</em></code>. Then, you could spend your third minute moving to valve <code>CC</code> and your fourth minute opening it, providing an additional <em>26 minutes</em> of eventual pressure release at a flow rate of <code>2</code>, or <code><em>52</em></code> total pressure released by valve <code>CC</code>.</p>
<p>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:</p>
<pre><code>== 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 <em>20</em> pressure.
You move to valve CC.
== Minute 4 ==
Valve DD is open, releasing <em>20</em> pressure.
You move to valve BB.
== Minute 5 ==
Valve DD is open, releasing <em>20</em> pressure.
You open valve BB.
== Minute 6 ==
Valves BB and DD are open, releasing <em>33</em> pressure.
You move to valve AA.
== Minute 7 ==
Valves BB and DD are open, releasing <em>33</em> pressure.
You move to valve II.
== Minute 8 ==
Valves BB and DD are open, releasing <em>33</em> pressure.
You move to valve JJ.
== Minute 9 ==
Valves BB and DD are open, releasing <em>33</em> pressure.
You open valve JJ.
== Minute 10 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve II.
== Minute 11 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve AA.
== Minute 12 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve DD.
== Minute 13 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve EE.
== Minute 14 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve FF.
== Minute 15 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve GG.
== Minute 16 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You move to valve HH.
== Minute 17 ==
Valves BB, DD, and JJ are open, releasing <em>54</em> pressure.
You open valve HH.
== Minute 18 ==
Valves BB, DD, HH, and JJ are open, releasing <em>76</em> pressure.
You move to valve GG.
== Minute 19 ==
Valves BB, DD, HH, and JJ are open, releasing <em>76</em> pressure.
You move to valve FF.
== Minute 20 ==
Valves BB, DD, HH, and JJ are open, releasing <em>76</em> pressure.
You move to valve EE.
== Minute 21 ==
Valves BB, DD, HH, and JJ are open, releasing <em>76</em> pressure.
You open valve EE.
== Minute 22 ==
Valves BB, DD, EE, HH, and JJ are open, releasing <em>79</em> pressure.
You move to valve DD.
== Minute 23 ==
Valves BB, DD, EE, HH, and JJ are open, releasing <em>79</em> pressure.
You move to valve CC.
== Minute 24 ==
Valves BB, DD, EE, HH, and JJ are open, releasing <em>79</em> pressure.
You open valve CC.
== Minute 25 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
== Minute 26 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
== Minute 27 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
== Minute 28 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
== Minute 29 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
== Minute 30 ==
Valves BB, CC, DD, EE, HH, and JJ are open, releasing <em>81</em> pressure.
</code></pre>
<p>This approach lets you release the most pressure possible in 30 minutes with this valve layout, <code><em>1651</em></code>.</p>
<p>Work out the steps to release the most pressure in 30 minutes. <em>What is the most pressure you can release?</em></p>
File diff suppressed because one or more lines are too long
+324 -1
View File
@@ -1 +1,324 @@
# Day 17 Puzzle Text.
<article class="day-desc"><h2>--- Day 17: Pyroclastic Flow ---</h2><p>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.</p>
<p>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 <span title="I am the man who arranges the blocks / that descend upon me from up above!">crushed</span>!</p>
<p>The five types of rocks have the following peculiar shapes, where <code>#</code> is rock and <code>.</code> is empty space:</p>
<pre><code>####
.#.
###
.#.
..#
..#
###
#
#
#
#
##
##
</code></pre>
<p>The rocks fall in the order shown above: first the <code>-</code> shape, then the <code>+</code> shape, and so on. Once the end of the list is reached, the same order repeats: the <code>-</code> shape falls first, sixth, 11th, 16th, etc.</p>
<p>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).</p>
<p>For example, suppose this was the jet pattern in your cave:</p>
<pre><code>&gt;&gt;&gt;&lt;&lt;&gt;&lt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&gt;&gt;&lt;&lt;&lt;&gt;&lt;&lt;&lt;&gt;&gt;&lt;&gt;&gt;&lt;&lt;&gt;&gt;
</code></pre>
<p>In jet patterns, <code>&lt;</code> means a push to the left, while <code>&gt;</code> 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.</p>
<p>The tall, vertical chamber is exactly <em>seven units wide</em>. 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).</p>
<p>After a rock appears, it alternates between <em>being pushed by a jet of hot gas</em> one unit (in the direction indicated by the next symbol in the jet pattern) and then <em>falling one unit down</em>. 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 <em>downward</em> 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.</p>
<p>Drawing falling rocks with <code>@</code> and stopped rocks with <code>#</code>, the jet pattern in the example above manifests as follows:</p>
<pre><code>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:
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|...#...|
|..###..|
|...#...|
|..####.|
+-------+
</code></pre>
<p>The moment each of the next few rocks begins falling, you would see this:</p>
<pre><code>|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|..#....|
|..#....|
|####...|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|...@...|
|..@@@..|
|...@...|
|.......|
|.......|
|.......|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|....@..|
|....@..|
|..@@@..|
|.......|
|.......|
|.......|
|..#....|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@....|
|..@....|
|..@....|
|..@....|
|.......|
|.......|
|.......|
|.....#.|
|.....#.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@...|
|..@@...|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|....##.|
|..####.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
|..@@@@.|
|.......|
|.......|
|.......|
|....#..|
|....#..|
|....##.|
|##..##.|
|######.|
|.###...|
|..#....|
|.####..|
|....##.|
|....##.|
|....#..|
|..#.#..|
|..#.#..|
|#####..|
|..###..|
|...#...|
|..####.|
+-------+
</code></pre>
<p>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 <code><em>3068</em></code> units tall.</p>
<p><em>How many units tall will the tower of rocks be after 2022 rocks have stopped falling?</em></p>
+2025 -1
View File
File diff suppressed because it is too large Load Diff
+23 -1
View File
@@ -1 +1,23 @@
# Day 18 Puzzle Text.
<article class="day-desc"><h2>--- Day 18: Boiling Boulders ---</h2><p>You and the elephants finally reach fresh air. You've emerged near the base of a large volcano that seems to be actively erupting! Fortunately, the lava seems to be flowing away from you and toward the ocean.</p>
<p>Bits of lava are still being ejected toward you, so you're sheltering in the cavern exit a little longer. Outside the cave, you can see the lava landing in a pond and hear it loudly hissing as it solidifies.</p>
<p>Depending on the specific compounds in the lava and speed at which it cools, it might be forming <a href="https://en.wikipedia.org/wiki/Obsidian" target="_blank">obsidian</a>! The cooling rate should be based on the surface area of the lava droplets, so you take a quick scan of a droplet as it flies past you (your puzzle input).</p>
<p>Because of how quickly the lava is moving, the scan isn't very good; its resolution is quite low and, as a result, it approximates the shape of the lava droplet with <em>1x1x1 <span title="Unfortunately, you forgot your flint and steel in another dimension.">cubes</span> on a 3D grid</em>, each given as its <code>x,y,z</code> position.</p>
<p>To approximate the surface area, count the number of sides of each cube that are not immediately connected to another cube. So, if your scan were only two adjacent cubes like <code>1,1,1</code> and <code>2,1,1</code>, each cube would have a single side covered and five sides exposed, a total surface area of <code><em>10</em></code> sides.</p>
<p>Here's a larger example:</p>
<pre><code>2,2,2
1,2,2
3,2,2
2,1,2
2,3,2
2,2,1
2,2,3
2,2,4
2,2,6
1,2,5
3,2,5
2,1,5
2,3,5
</code></pre>
<p>In the above example, after counting up all the sides that aren't connected to another cube, the total surface area is <code><em>64</em></code>.</p>
<p><em>What is the surface area of your scanned lava droplet?</em></p>
+30 -1
View File
@@ -1 +1,30 @@
Paste any inputs into this file. Blueprint 1: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 3 ore and 8 obsidian.
Blueprint 2: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 9 clay. Each geode robot costs 2 ore and 10 obsidian.
Blueprint 3: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 20 clay. Each geode robot costs 2 ore and 12 obsidian.
Blueprint 4: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 13 obsidian.
Blueprint 5: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 16 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 6: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 18 clay. Each geode robot costs 4 ore and 20 obsidian.
Blueprint 7: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 11 clay. Each geode robot costs 4 ore and 12 obsidian.
Blueprint 8: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 20 clay. Each geode robot costs 2 ore and 20 obsidian.
Blueprint 9: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 2 ore and 11 clay. Each geode robot costs 4 ore and 8 obsidian.
Blueprint 10: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 5 clay. Each geode robot costs 3 ore and 15 obsidian.
Blueprint 11: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 15 clay. Each geode robot costs 2 ore and 15 obsidian.
Blueprint 12: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 19 clay. Each geode robot costs 3 ore and 10 obsidian.
Blueprint 13: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 16 clay. Each geode robot costs 2 ore and 18 obsidian.
Blueprint 14: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 4 ore and 7 obsidian.
Blueprint 15: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 3 ore and 13 obsidian.
Blueprint 16: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 14 clay. Each geode robot costs 3 ore and 16 obsidian.
Blueprint 17: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 6 clay. Each geode robot costs 3 ore and 16 obsidian.
Blueprint 18: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 4 ore and 12 obsidian.
Blueprint 19: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 17 clay. Each geode robot costs 4 ore and 20 obsidian.
Blueprint 20: Each ore robot costs 3 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 16 clay. Each geode robot costs 3 ore and 15 obsidian.
Blueprint 21: Each ore robot costs 3 ore. Each clay robot costs 3 ore. Each obsidian robot costs 3 ore and 19 clay. Each geode robot costs 2 ore and 9 obsidian.
Blueprint 22: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 20 clay. Each geode robot costs 2 ore and 17 obsidian.
Blueprint 23: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 7 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 24: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 9 clay. Each geode robot costs 3 ore and 9 obsidian.
Blueprint 25: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 2 ore and 15 clay. Each geode robot costs 2 ore and 8 obsidian.
Blueprint 26: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 16 clay. Each geode robot costs 3 ore and 13 obsidian.
Blueprint 27: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 18 clay. Each geode robot costs 4 ore and 11 obsidian.
Blueprint 28: Each ore robot costs 4 ore. Each clay robot costs 3 ore. Each obsidian robot costs 4 ore and 8 clay. Each geode robot costs 3 ore and 7 obsidian.
Blueprint 29: Each ore robot costs 2 ore. Each clay robot costs 4 ore. Each obsidian robot costs 4 ore and 20 clay. Each geode robot costs 3 ore and 14 obsidian.
Blueprint 30: Each ore robot costs 4 ore. Each clay robot costs 4 ore. Each obsidian robot costs 3 ore and 11 clay. Each geode robot costs 3 ore and 8 obsidian.
+155 -1
View File
@@ -1 +1,155 @@
# Day 19 Puzzle Text.
<article class="day-desc"><h2>--- Day 19: Not Enough Minerals ---</h2><p>Your scans show that the lava did indeed form obsidian!</p>
<p>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 <a href="https://en.wikipedia.org/wiki/Geode" target="_blank">geodes</a> around the pond. Perhaps you could use the obsidian to create some <em>geode-cracking robots</em> and break them open?</p>
<p>To collect the obsidian from the bottom of the pond, you'll need waterproof <em>obsidian-collecting robots</em>. Fortunately, there is an abundant amount of clay nearby that you can use to make them waterproof.</p>
<p>In order to harvest the clay, you'll need special-purpose <em>clay-collecting robots</em>. To make any type of robot, you'll need <em>ore</em>, which is also plentiful but in the opposite direction from the clay.</p>
<p>Collecting ore requires <em>ore-collecting robots</em> with big drills. Fortunately, <em>you have exactly one ore-collecting robot</em> in your pack that you can use to <span title="If You Give A Mouse An Ore-Collecting Robot">kickstart</span> the whole operation.</p>
<p>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.</p>
<p>The robot factory has many <em>blueprints</em> (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.</p>
<p>For example:</p>
<pre><code>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.
</code></pre>
<p>(Blueprints have been line-wrapped here for legibility. The robot factory's actual assortment of blueprints are provided one blueprint per line.)</p>
<p>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 <em>24 minutes</em> by figuring out which robots to build and when to build them.</p>
<p>Using blueprint 1 in the example above, the largest number of geodes you could open in 24 minutes is <code><em>9</em></code>. One way to achieve that is:</p>
<pre><code>== 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.
</code></pre>
<p>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 <code><em>12</em></code>.</p>
<p>Determine the <em>quality level</em> of each blueprint by <em>multiplying that blueprint's ID number</em> 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 <code><em>9</em></code>. The second blueprint has ID 2 and can open 12 geodes, so its quality level is <code><em>24</em></code>. Finally, if you <em>add up the quality levels</em> of all of the blueprints in the list, you get <code><em>33</em></code>.</p>
<p>Determine the quality level of each blueprint using the largest number of geodes it could produce in 24 minutes. <em>What do you get if you add up the quality level of all of the blueprints in your list?</em></p>
+5000 -1
View File
File diff suppressed because it is too large Load Diff
+45 -1
View File
@@ -1 +1,45 @@
# Day 20 Puzzle Text.
<article class="day-desc"><h2>--- Day 20: Grove Positioning System ---</h2><p>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?</p>
<p>You know they're headed to the grove where the <em class="star">star</em> fruit grows, so if you can figure out where that is, you should be able to meet back up with them.</p>
<p>Fortunately, your handheld device has a file (your puzzle input) that contains the grove's coordinates! Unfortunately, the file is <em>encrypted</em> - just in case the device were to fall into the wrong hands.</p>
<p>Maybe you can <span title="You once again make a mental note to remind the Elves later not to invent their own cryptographic functions.">decrypt</span> it?</p>
<p>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 <em>mixing</em>.</p>
<p>The encrypted file is a list of numbers. To <em>mix</em> 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 <em>circular</em>, so moving a number off one end of the list wraps back around to the other end as if the ends were connected.</p>
<p>For example, to move the <code>1</code> in a sequence like <code>4, 5, 6, <em>1</em>, 7, 8, 9</code>, the <code>1</code> moves one position forward: <code>4, 5, 6, 7, <em>1</em>, 8, 9</code>. To move the <code>-2</code> in a sequence like <code>4, <em>-2</em>, 5, 6, 7, 8, 9</code>, the <code>-2</code> moves two positions backward, wrapping around: <code>4, 5, 6, 7, 8, <em>-2</em>, 9</code>.</p>
<p>The numbers should be moved <em>in the order they originally appear</em> in the encrypted file. Numbers moving around during the mixing process do not change the order in which the numbers are moved.</p>
<p>Consider this encrypted file:</p>
<pre><code>1
2
-3
3
-2
0
4
</code></pre>
<p>Mixing this file proceeds as follows:</p>
<pre><code>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
</code></pre>
<p>Then, the grove coordinates can be found by looking at the 1000th, 2000th, and 3000th numbers after the value <code>0</code>, wrapping around the list as necessary. In the above example, the 1000th number after <code>0</code> is <code><em>4</em></code>, the 2000th is <code><em>-3</em></code>, and the 3000th is <code><em>2</em></code>; adding these together produces <code><em>3</em></code>.</p>
<p>Mix your encrypted file exactly once. <em>What is the sum of the three numbers that form the grove coordinates?</em></p>
+1579 -1
View File
File diff suppressed because it is too large Load Diff
+34 -1
View File
@@ -1 +1,34 @@
# Day 21 Puzzle Text.
<article class="day-desc"><h2>--- Day 21: Monkey Math ---</h2><p>The <a href="11">monkeys</a> 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.</p>
<p>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 <em>riddle</em>.</p>
<p>Each monkey is given a <em>job</em>: either to <em>yell a specific number</em> or to <em>yell the result of a math operation</em>. 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 <em>also</em> be waiting on other monkeys.</p>
<p>Your job is to <em>work out the number the monkey named <code>root</code> will yell</em> before the monkeys figure it out themselves.</p>
<p>For example:</p>
<pre><code>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
</code></pre>
<p>Each line contains the name of a monkey, a colon, and then the job of that monkey:</p>
<ul>
<li>A lone number means the monkey's job is simply to yell that number.</li>
<li>A job like <code>aaaa + bbbb</code> means the monkey waits for monkeys <code>aaaa</code> and <code>bbbb</code> to yell each of their numbers; the monkey then yells the sum of those two numbers.</li>
<li><code>aaaa - bbbb</code> means the monkey yells <code>aaaa</code>'s number minus <code>bbbb</code>'s number.</li>
<li>Job <code>aaaa * bbbb</code> will yell <code>aaaa</code>'s number multiplied by <code>bbbb</code>'s number.</li>
<li>Job <code>aaaa / bbbb</code> will yell <code>aaaa</code>'s number divided by <code>bbbb</code>'s number.</li>
</ul>
<p>So, in the above example, monkey <code>drzm</code> has to wait for monkeys <code>hmdt</code> and <code>zczc</code> to yell their numbers. Fortunately, both <code>hmdt</code> and <code>zczc</code> have jobs that involve simply yelling a single number, so they do this immediately: <code>32</code> and <code>2</code>. Monkey <code>drzm</code> can then yell its number by finding <code>32</code> minus <code>2</code>: <code><em>30</em></code>.</p>
<p>Then, monkey <code>sjmn</code> has one of its numbers (<code>30</code>, from monkey <code>drzm</code>), and already has its other number, <code>5</code>, from <code>dbpl</code>. This allows it to yell its own number by finding <code>30</code> multiplied by <code>5</code>: <code><em>150</em></code>.</p>
<p>This process continues until <code>root</code> yells a number: <code><em>152</em></code>.</p>
<p>However, your actual situation involves <span title="Advent of Code 2022: Now With Considerably More Monkeys">considerably more monkeys</span>. <em>What number will the monkey named <code>root</code> yell?</em></p>
+202 -1
View File
File diff suppressed because one or more lines are too long
+62 -1
View File
@@ -1 +1,62 @@
# Day 22 Puzzle Text.
<article class="day-desc"><h2>--- Day 22: Monkey Map ---</h2><p>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.</p>
<p>As you walk, the monkeys explain that the grove is protected by a <em>force field</em>. To pass through the force field, you have to enter a password; doing so involves tracing a specific <em>path</em> on a strangely-shaped board.</p>
<p>At least, you're pretty sure that's what you have to do; the elephants aren't exactly fluent in monkey.</p>
<p>The monkeys give you notes that they took when they last saw the password entered (your puzzle input).</p>
<p>For example:</p>
<pre><code> ...#
.#..
#...
....
...#.......#
........#...
..#....#....
..........#.
...#....
.....#..
.#......
......#.
10R5L5R10L4R5L5
</code></pre>
<p>The first half of the monkeys' notes is a <em>map of the board</em>. It is comprised of a set of <em>open tiles</em> (on which you can move, drawn <code>.</code>) and <em>solid walls</em> (tiles which you cannot enter, drawn <code>#</code>).</p>
<p>The second half is a description of <em>the path you must follow</em>. It consists of alternating numbers and letters:</p>
<ul>
<li>A <em>number</em> indicates the <em>number of tiles to move</em> in the direction you are facing. If you run into a wall, you stop moving forward and continue with the next instruction.</li>
<li>A <em>letter</em> indicates whether to turn 90 degrees <em>clockwise</em> (<code>R</code>) or <em><span title="Or &quot;anticlockwise&quot;, if you're anti-counterclockwise.">counterclockwise</span></em> (<code>L</code>). Turning happens in-place; it does not change your current tile.</li>
</ul>
<p>So, a path like <code>10R5</code> means "go forward 10 tiles, then turn clockwise 90 degrees, then go forward 5 tiles".</p>
<p>You begin the path in the leftmost open tile of the top row of tiles. Initially, you are facing <em>to the right</em> (from the perspective of how the map is drawn).</p>
<p>If a movement instruction would take you off of the map, you <em>wrap around</em> 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.</p>
<p>For example, if you are at <code>A</code> and facing to the right, the tile in front of you is marked <code>B</code>; if you are at <code>C</code> and facing down, the tile in front of you is marked <code>D</code>:</p>
<pre><code> ...#
.#..
#...
....
...#.<em>D</em>.....#
........#...
<em>B</em>.#....#...<em>A</em>
.....<em>C</em>....#.
...#....
.....#..
.#......
......#.
</code></pre>
<p>It is possible for the next tile (after wrapping around) to be a <em>wall</em>; 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.</p>
<p>By drawing the <em>last facing you had</em> with an arrow on each tile you visit, the full path taken by the above example looks like this:</p>
<pre><code> &gt;&gt;v#
.#v.
#.v.
..v.
...#...v..v#
&gt;&gt;&gt;v...<em>&gt;</em>#.&gt;&gt;
..#v...#....
...&gt;&gt;&gt;&gt;v..#.
...#....
.....#..
.#......
......#.
</code></pre>
<p>To finish providing the password to this strange input device, you need to determine numbers for your final <em>row</em>, <em>column</em>, and <em>facing</em> as your final position appears from the perspective of the original map. Rows start from <code>1</code> at the top and count downward; columns start from <code>1</code> 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 <code>0</code> for right (<code>&gt;</code>), <code>1</code> for down (<code>v</code>), <code>2</code> for left (<code>&lt;</code>), and <code>3</code> for up (<code>^</code>). The <em>final password</em> is the sum of 1000 times the row, 4 times the column, and the facing.</p>
<p>In the above example, the final row is <code>6</code>, the final column is <code>8</code>, and the final facing is <code>0</code>. So, the final password is 1000 * 6 + 4 * 8 + 0: <code><em>6032</em></code>.</p>
<p>Follow the path given in the monkeys' notes. <em>What is the final password?</em></p>
+74 -1
View File
@@ -1 +1,74 @@
Paste any inputs into this file. #.#..#...#..##.#..##.##.###.#..#...#.############.###.####.....##.#.......
...#..#..##......#.......###.#..##.#.#.#...#..#.#.#.#...###.#..#...#.....#
##..###..##.####....##.#...#....##.....#.##..#####..##..###.#.#.#.##......
.#.#.##.#..##....#..#...#.#.##.#...##.##.##....#...####..#.###..#.#..##.#.
##..##.##..#.#####..#..#####..##.###.##.#..#.#....#.#.##.###..#####.#...##
.#..#.#.##.....##.#.####...##.#.......##.#.#.######.#....#####.#####..#..#
##....#...##.#.....##..#.#...######.#..#.##.###..###.#.##.##.#..#....#..##
.#.###..###.##.#...#.#.##.#.#...#####.##.#.##.######..######.##...###.##..
#.#..##....#....#..####.#..###.#...#.#.########.#....#..#...#.#..#..####..
....#.#.##..#.#######...##...##.#..#.#.###.###...##...##.#...##...#.#####.
....#.####..#......#..#....#..###...#.#....#.##...#.#....#####..#..#.#...#
#......#..#######..#...####...#.#.##.#..###.....#.#.####.#.#.#.##.##.##.##
.###.....##..###..####.##..###....#..#...###..##..##..#.####.##.#......###
###...#.........#.#.....####....##.###.####.###.#....##.#..#.#..##...#..##
..#.#.#####.#..#.#.######.#####....#.#...#..#.##..#..#.#..##..#..##.###...
##.#####.##.#...#.#.#...#...#..........#.#.#..####.#...##.######..###...##
..#.#.####..##..#.#..#####.#.##..#..#.##....###.##.##..#.#...##.##..##.##.
###..#.######.##...##.##.####....#.##.#.#.#...#..#....##..####..##.#.#.##.
.##.##.###.....####..###....#.#..##..#.#..#..##..#.##.##...##..#.#.#..###.
....#.####...######.....########.#.#....##.#..###..#.###..###.#..#.#....##
.#..###.#.#.#.#.#..#...####.#.#.##....#..#...#....##.....####...####.#.###
#.##...###.#####.##.###.#....##..#.....##..#...#..##.#...#..##...##.#.##.#
...#..####..##....###......######.#.#.#..#######...##.#..####.....#.#.####
...#.####....###.##.#.#.#..##..#...#.##.#...#.###..#..#....###.##.....#..#
#..#.#.##...#......##.##..#..####..##..###.###.#.###.##....#....###.##..#.
.#..#..####.#.#.###.###.####.#....#.####....#.##.##....#......#.####.##..#
...####.#...#.#....#.#......#.#.#..##.##.##....##...##......##.####.##....
.....#..#.##.##..#..##...###..#..#.#...####.#.##...##.#####.#..#..#..#####
..##.#...###....#...##.#.#.......#....####..##........#...#..###..#..###..
####...###...#....####.##...##.####..##.##...#####.####..###..##.##.#.###.
...........###....#....#...#..##..###...#..#.#..#.#.#....####.#.#..####...
.#.##.###.#.##..##..######.####....#.####...#..#...#..##..######.#.##.####
.###..#.#..##..##...#...#...####.....##..#..##.#..##....#...#..##.#..#.#..
.#.###.#...##..#..#..###...#.##.#.#.....#.#.#...#...##.#.##.#...##....#..#
.##.##..#.#.#..#.#######.###..###.#.#####..#.###.####..###...#.#.##....#..
.....###.####.#####.###....##.##.##.##...###.#.#.#...####...###....#...###
##.....#..#....#.###..##...##.#.#..###.#.#..###.#####.##.##.##.#...###.##.
.#..#.#####....#.#.#.#..#.####...#...#..###..##.######..#.#..####..##.##..
.#....#..#....#.##.#.#.##..#.#..###..##..##..###..#.#######..####..###.#..
#.#.##.##.#.##.##..#...#..###..###.#.....#.###.#..####.#..#####...###.#.#.
...#.#.##..#.#...#.#..#..####.#...###....#.....#.....#.##.####.#...####.##
##.###.##..#..##.###.#..#..#.###.###.##.##...#.#..####....##.#####...#.#.#
###.....#.#.##.#...#.#...##.##.#..####.##...#.#.#####....#..#####...#.#.#.
##.######.#.#....#....#.#####.....####....###.#.#...##.#..#.##.#.##..##.#.
##...##.##.#..#.#......#.####..###..###..#....###..#..#########..#.###.#..
#.#..###..#...#.#.#####.#.##..#..#.#.#.#..#.##.####.####..#.#..##.##.####.
###########.#..###..#.##.###.#.#.#.#..##.##...#...###..##..###.##...##.#.#
..#.##..###....#.#..#.......#.##..##.######..#####.##.##........##....#...
.#..#.##.#..#......##.#..##.#.##.###..###.#....##..###.#.#.#...#.##.#...##
#####..##..##.#..###...##.#...#.##.#..#....##..#..#...#.#...##.###...#.#.#
#.#.#.....###.#.#.##.......#....#.####.########..#.##.##...#.#.#....##....
.###.#...###..#####..##..#.#.##.####.###.#....##.#..##..#...#.....#####.#.
#####.#..#.###...##.#..##.##...####...####..###...###......#..#.#.......##
###....#.##.#.#.#.####.##.###...##.#.#...#..#.....#.##########...########.
###...###.#..#....#.#.#...#...#...#.#####...##..#.....##..##...#.#.#.##.#.
##.##.#..###....#..#.#.#####...##....#....#...###....#..#..#.#.#...##..###
...#..##..###..#.####..#.#.#....##.##.#.#...#....###...#.##......##.#.###.
.#.######.#######..#..#.#..##..#..#.##.#...####..##########..#.##..#.#.###
.#.#...#..##.#...#..##.#..##......#.###.###.#.##.###...#....#...########.#
.##.#....#..#.#.##..#.#####...##.#.##.##..#.#.##.##.#.#...#.#...#....##.##
..##.###.###...#...##...#.##..###.....##.#.####.###.......#....##.##.##...
.####.#.###.##.#...###.#######..#.....###..#..##.#..##......#..##.##..###.
##..#.#####.##...##..###.######..#.#.##...##.#.#.##.#..#....###.##..#..###
.###....###...#...#...#.#..###.#.##..###.#...##..#..#...##...##....#.####.
.##.#.#.##..#.#.#..#..####...###.##..##.##..###..#####..###...#.#.########
.##..##..##....#....#.#.#.##.#....#....#..###.####.##..##...#.##..##.....#
..#.###..#.##..#..#.##.######.#.###.#..##.....#####.#########..##...#..#.#
#.####...#..#..#.###..##.#.#...#....##.#####.#..#...##..##.#..#..###....#.
##...#....#######.###.###..#.##....####.#.#...#.#.#...####..#.#..#.###.#..
##.#.####..###.###.###...#..#.#..#..#....##..#..###.#...#.#.#..#.##.##.##.
##....#..#..#.#.##.##.#...#...#####....##..#..####.#.#..#...###.###..###..
#.#.#.##......#..#..##...#.....##.##..####..###....#.#..#...####..#.##....
.#.###.#..#.#..#..###.....##.#.#.##....##...##.#.#.##.#.#..##..##..#......
###...##.###..#.##.#.#..#.##..##.#...##..###.#........#.#.#...#.#.#.#.....
+179 -1
View File
@@ -1 +1,179 @@
# Day 23 Puzzle Text.
<article class="day-desc"><h2>--- Day 23: Unstable Diffusion ---</h2><p>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.</p>
<p>"...but this volcano has been dormant for months. Without ash, the fruit can't grow!"</p>
<p>You look up to see a massive, snow-capped mountain towering above you.</p>
<p>"It's not like there are other active volcanoes here; we've looked everywhere."</p>
<p>"But our scanners show active magma flows; clearly it's going <em>somewhere</em>."</p>
<p>They finally notice you at the edge of the grove, your pack almost overflowing from the random <em class="star">star</em> 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.</p>
<p>"Why do you--" "How is--" "Did you just--"</p>
<p>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!"</p>
<p>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.</p>
<p>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.</p>
<p>For example:</p>
<pre><code>....#..
..###.#
#...#.#
.#...##
#.###..
##.#.##
.#..#..
</code></pre>
<p>The scan shows Elves <code>#</code> and empty ground <code>.</code>; outside your scan, more empty ground extends a long way in every direction. The scan is oriented so that <em>north is up</em>; orthogonal directions are written N (north), S (south), W (west), and E (east), while diagonal directions are written NE, NW, SE, SW.</p>
<p>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 <em>rounds</em> during which Elves alternate between considering where to move and actually moving.</p>
<p>During the <em>first half</em> 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 <em>does not do anything</em> during this round. Otherwise, the Elf looks in each of four directions in the following order and <em>proposes</em> moving one step in the <em>first valid direction</em>:</p>
<ul>
<li>If there is no Elf in the N, NE, or NW adjacent positions, the Elf proposes moving <em>north</em> one step.</li>
<li>If there is no Elf in the S, SE, or SW adjacent positions, the Elf proposes moving <em>south</em> one step.</li>
<li>If there is no Elf in the W, NW, or SW adjacent positions, the Elf proposes moving <em>west</em> one step.</li>
<li>If there is no Elf in the E, NE, or SE adjacent positions, the Elf proposes moving <em>east</em> one step.</li>
</ul>
<p>After each Elf has had a chance to propose a move, the <em>second half</em> of the round can begin. Simultaneously, each Elf moves to their proposed destination tile if they were the <em>only</em> Elf to propose moving to that position. If two or more Elves propose moving to the same position, <em>none</em> of those Elves move.</p>
<p>Finally, at the end of the round, the <em>first direction</em> 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.</p>
<p>As a smaller example, consider just these five Elves:</p>
<pre><code>.....
..##.
..#..
.....
..##.
.....
</code></pre>
<p>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:</p>
<pre><code>..##.
.....
..#..
...#.
..#..
.....
</code></pre>
<p>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 <em>or</em> west and proposes moving east. All five Elves succeed in moving to their proposed positions:</p>
<pre><code>.....
..##.
.#...
....#
.....
..#..
</code></pre>
<p>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:</p>
<pre><code>..#..
....#
#....
....#
.....
..#..
</code></pre>
<p>At this point, no Elves need to move, and so the process ends.</p>
<p>The larger example above proceeds as follows:</p>
<pre><code>== Initial State ==
..............
..............
.......#......
.....###.#....
...#...#.#....
....#...##....
...#.###......
...##.#.##....
....#..#......
..............
..............
..............
== End of Round 1 ==
..............
.......#......
.....#...#....
...#..#.#.....
.......#..#...
....#.#.##....
..#..#.#......
..#.#.#.##....
..............
....#..#......
..............
..............
== End of Round 2 ==
..............
.......#......
....#.....#...
...#..#.#.....
.......#...#..
...#..#.#.....
.#...#.#.#....
..............
..#.#.#.##....
....#..#......
..............
..............
== End of Round 3 ==
..............
.......#......
.....#....#...
..#..#...#....
.......#...#..
...#..#.#.....
.#..#.....#...
.......##.....
..##.#....#...
...#..........
.......#......
..............
== End of Round 4 ==
..............
.......#......
......#....#..
..#...##......
...#.....#.#..
.........#....
.#...###..#...
..#......#....
....##....#...
....#.........
.......#......
..............
== End of Round 5 ==
.......#......
..............
..#..#.....#..
.........#....
......##...#..
.#.#.####.....
...........#..
....##..#.....
..#...........
..........#...
....#..#......
..............
</code></pre>
<p>After a few more rounds...</p>
<pre><code>== End of Round 10 ==
.......#......
...........#..
..#.#..#......
......#.......
...#.....#..#.
.#......##....
.....##.......
..#........#..
....#.#..#....
..............
....#..#..#...
..............
</code></pre>
<p>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 <span title="Arbitrary Rectangles is my Piet Mondrian cover band.">arbitrary rectangles</span>.) In the above example, that rectangle is:</p>
<pre><code>......#.....
..........#.
.#.#..#.....
.....#......
..#.....#..#
#......##...
....##......
.#........#.
...#.#..#...
............
...#..#..#..
</code></pre>
<p>In this region, the number of empty ground tiles is <code><em>110</em></code>.</p>
<p>Simulate the Elves' process and find the smallest rectangle that contains the Elves after 10 rounds. <em>How many empty ground tiles does that rectangle contain?</em></p>
+37 -1
View File
@@ -1 +1,37 @@
Paste any inputs into this file. #.####################################################################################################
#<<<..>>><v<><><v^<><^vv^<<v<^<>>.v^vvvv<v.>v^<<v>>.v>><..<v^>v>.v^v>.><>>^><<.vv<^<>>^v<^.<>>>vvv^v<#
#>><vv.^v>>v>v.v^^^.><^<>>v.^>v^>v><.^>><>>^^.vvv^^^>^>^<vvv.<^.>.><>v.>vv<v.^>>^<><>><>v<v^.>^^^<.<<#
#>>v<v>vv<^^^^^<<v><<^v>^<vv^.v>>.>vv^v<^^..v^>><<>^>v>v<^v.><^<^^v><^^vv<.v..<^<.>^>^<^^^><^<v<^>>v>#
#<v<<<v<.^^^<>v^^^v<v^<<>.v<><v.<<<<><v^>>vv>^>v.^v..<><.<><^.<v^>^<^^<^<v.v.^<v><>v>..>>^^>>^^vv>v>>#
#>^v<><>vvv>>>v^^<^v<v<<<^<.<v^v^^.vvvvv<>vvvv^>v<v^v><<>...>v<^>^.^^^<><^.v<^v>^<v^^<<v^<^<>vv^>^><>#
#<<<<><>^<>><v<^^^>^>v<.^<^<.v<.><><<v<^^><v><>^^.^>>>v^<v^><^^.^<<<.v^>^^<^>^><^^.^v><v^>^<vv^v^<<><#
#>^>v><<<>>.v.>v<^^v<.vvv^vv>>v^v^^><^><>>.>^>^v^v><^v.v<^<v<<v<vv^v<^<<><<v><..^^<.v.v><^<.><>^>>>v<#
#<^^v<.<.vv>>vv<.<.<>><v^^>vv><v<>v^.v>v<.>v^>>>^.v>^<>v<<^vv>^<v^>^><^<v^^<v><>v.>vv^v<<v.vv^>v^...<#
#>^v>>><>^.^<v^<^<^<>>v<>^>>v><^<<v^^>>^.^<<v>.^>>^^><^^v<v.v<^v>>v><>^<>>v^v^<>^<^<^v<vv<v<vv<>^>><.#
#<<>^v<^^^<^<<<.vvv><v><^.<>v>^>v^v.v<<<>.<>vv>v>v>..^.^v<<v<>v^>vv<>v<v>^>>^^<>^.<>^v^<>v^^><<<v^<<<#
#<.>>>><.>^v<^<>.v>^^<v^v.<.^..v^v>^v.<v^.v.vv.>.<v^....>^>v^v>^^^>v<^<^<^^^>><.^>v<<v^<.<v^<.>>>v^>.#
#<.>v<v><>>^^><v^<>^>>v>>^<v>.v^><..^vv^>><><.<^<><^^v^<^^>>v<>^<^>v^<^>v<<^>.<>v^<^v><>v^^vv<<vv<>><#
#><^^.^>>^^vv.vv^v<v<.^<.>v^>>v^^<<<>^<<>^v^v>.^<^.><v>>^v>><v<>.<>.>v<^<^v.<v>^^vv^^>>v.>^.<>.^<^.v>#
#>v<^^^v^^<^v^>^<^^^.>^^<^.>v<<><>vv<>..^^<^>>>><<>v<<v^^^>v.<>>^<v^>^<<v.^..>^>v^^.<<>><v<.>>v^<^v>.#
#<><.^<^^^^.><<^v.^<><vv<v<<v<^v^>^<^v^><>vv>v<<v><<<<><<.>^vv<v.^v<^>^<>>>v<vvvv^^<<<^><^v><<vv><>v.#
#>>v>v<>vvv>^>v<^<>><>v<vv.v<^^^vv>v<vv<>>>v..^.<>vv>^v>>^.<>^>v^.<<<v>v^<v><^^v..><^v<^^^v<.^^^v><^<#
#.>^.>>^><vvv<^vv^>v^v^<..>>^<^>^^vv>^v<^^..^v^^^<<^<v.<>><<>v<v<^^.>^vv><>v^v^v>v^>v^.v^vv>^><^>>^<>#
#><<v^<^>.>vv^v><^^^<v^<<>>.v<.^<.v^^v^^^v<v^>v><><v><<v>>>^<v^.^v^v^>>^v.v>><>^<.><.^vv<vvv.>v.vv^v<#
#<<^v><<^>.vv.>v>^>><^>.<<>v><^>v<v>^<>>>^v<<vvvvv^vv^>>.<>>^><>.>>v^>^v.v^^^^.<^.^vvv<>v<<v>^v^v<.>>#
#<^^>^>^..v<v^^.^>>v^^>v^.^>vv>vv><.>>><v^<><v>.<^<<<><<<<v>v^.v.^v^>^..^<.vv><<<^v^.>.<<<<v>>^<^vvv>#
#>>^^<.^^v>^^>^>>>^v^<v...<>v^<^>^>^v^><>.^><v^.<<v.^<><^<>^>^.<v>.^^>^<>.^<^<><<>><>v.^.<>>>>vv^>>.<#
#><v>.>v>vv<>v^^v>^v><^.<^<<<^v.>v^v<>>v><><>^^.><vvv^.^>>^^<^>^>>^vv<<>>^>>>^<>v>.^^^<<.v<<<v>>><v<>#
#<^v.v<v>^>v.<<.>vv^<><>>>.<^.><>>^^>v<>..>^<^^v^.<^^.><>v<<^.^vv<>v^^<v>^.v<vv>vv.^v^><<<^<<>v<>^v>>#
#><v^<>>^^><^>v.><>.^>v>vv>v>>v^>.^><^^.^<v><.<<.>v.>.<><^^^^>^v>^<><<v>v^<<>v<<^<v>v<.<<v>.><^^>^>v>#
#>^<<..^v>.v<>^.<<>v><.^^^><^><>vv>^.<<<^v^^^>^.<.v><v<<.<<^<<^>>v><<vvv.<>.^vv^^>v.>.v>^><>.<^^<vv^<#
#>><^^>v><^v^<vvv>^.<.v^>>><<>v<^.v>v><<<>..><.^^.>^^>>vv<<.>^<.^^>v^v>^..v>>>v<><>^.v<.>^>^.>.>^<^<<#
#>^^<.>vv<>vv>^>.^^>v^^<^<v^<<vv>v<<^vv<<v<<>.v^><v<.>v^>>^v<<v.<^.>^>v^>v<vv<^>^<^v^<<vv^<v>^>v<^.^<#
#><><v<.<^^v<.v<>^^^.>><^.vvv^<>>v>^^<.v>>.>^<v^><^..<..^<><>.v>^v<<>..vv>vvv^.v>v><<v..^^^<>>><^<>><#
#<v<>>>v>^v><vv^^>.<><<>>^v>^^><.<<<^.v.<^>>v.^v.<v^^.^.<v^><v<<<>v^><^>v<<^v^^>v><.<^.v<.<>>v<^v^>>>#
#<.v^vv<<^^..<^<>^><>>vv^^^<.<^<<^<.^>>^^.<><>^>^v>vv>v.^>v><vvv^<<>v>>^^.>>>vv<>^^v<.<><>>.<<<^^>>><#
#<v<^>^vv^><>>v^<^v<v<.^<^^vvvvv>><^><^>v<>v<^v<v..>>^^><v^<^.<v>>^^.>^.>>.v<v>v^^^^<.vvv<v>^<.v..^<.#
#>><><^^^^>^^<^^v>>.>><.>><^v^>^^>v>^<v.<^v^<<.<v.>^><^^^^v.>>v<^>>>^>><>^.^<^v><>^<.>>^<v<><vv^v^v>>#
#.>.v<^<>>v.v>^><^<v><v<^>><^vv>v^<^v><^v>.^v>v^.>..^<><<<><<vv.^<>vv<^<^v^v.^><>v<^^^^^.<<vvvv<>^^v<#
#<>>^>>>v^^vv>><>vv^.v<>^v^^v>^<v^vv<^^vv>^<v<.>>v^v^>v^<>><<<v.^vv<^><>>v<vv^vv^<<^v^^>.>v>v.^^^<<<>#
#<<^v^.^v<vv.^>v<v^vvv^<v.<.>>^<^<<<<^<<<.><><v>^><<<<vv^v.vv^>>^>^>v<^<^^>v<>^^>vv>^v..v^v^<<v<<<v<.#
####################################################################################################.#
+224 -1
View File
@@ -1 +1,224 @@
# Day 24 Puzzle Text.
<article class="day-desc"><h2>--- Day 24: Blizzard Basin ---</h2><p>With everything replanted for next year (and with elephants and monkeys to tend the grove), you and the Elves leave for the extraction point.</p>
<p>Partway up the mountain that shields the grove is a flat, open area that serves as the extraction point. It's a bit of a climb, but nothing the expedition can't handle.</p>
<p>At least, that would normally be true; now that the mountain is covered in snow, things have become more difficult than the Elves are used to.</p>
<p>As the expedition reaches a valley that must be traversed to reach the extraction site, you find that strong, turbulent winds are pushing small <em>blizzards</em> of snow and sharp ice around the valley. It's a good thing everyone packed warm clothes! To make it across safely, you'll need to find a way to avoid them.</p>
<p>Fortunately, it's easy to see all of this from the entrance to the valley, so you make a map of the valley and the blizzards (your puzzle input). For example:</p>
<pre><code>#.#####
#.....#
#&gt;....#
#.....#
#...v.#
#.....#
#####.#
</code></pre>
<p>The walls of the valley are drawn as <code>#</code>; everything else is ground. Clear ground - where there is currently no blizzard - is drawn as <code>.</code>. Otherwise, blizzards are drawn with an arrow indicating their direction of motion: up (<code>^</code>), down (<code>v</code>), left (<code>&lt;</code>), or right (<code>&gt;</code>).</p>
<p>The above map includes two blizzards, one moving right (<code>&gt;</code>) and one moving down (<code>v</code>). In one minute, each blizzard moves one position in the direction it is pointing:</p>
<pre><code>#.#####
#.....#
#.&gt;...#
#.....#
#.....#
#...v.#
#####.#
</code></pre>
<p>Due to <span title="I think, anyway. Do I look like a theoretical blizzacist?">conservation of blizzard energy</span>, as a blizzard reaches the wall of the valley, a new blizzard forms on the opposite side of the valley moving in the same direction. After another minute, the bottom downward-moving blizzard has been replaced with a new downward-moving blizzard at the top of the valley instead:</p>
<pre><code>#.#####
#...v.#
#..&gt;..#
#.....#
#.....#
#.....#
#####.#
</code></pre>
<p>Because blizzards are made of tiny snowflakes, they pass right through each other. After another minute, both blizzards temporarily occupy the same position, marked <code>2</code>:</p>
<pre><code>#.#####
#.....#
#...2.#
#.....#
#.....#
#.....#
#####.#
</code></pre>
<p>After another minute, the situation resolves itself, giving each blizzard back its personal space:</p>
<pre><code>#.#####
#.....#
#....&gt;#
#...v.#
#.....#
#.....#
#####.#
</code></pre>
<p>Finally, after yet another minute, the rightward-facing blizzard on the right is replaced with a new one on the left facing the same direction:</p>
<pre><code>#.#####
#.....#
#&gt;....#
#.....#
#...v.#
#.....#
#####.#
</code></pre>
<p>This process repeats at least as long as you are observing it, but probably forever.</p>
<p>Here is a more complex example:</p>
<pre><code>#.######
#&gt;&gt;.&lt;^&lt;#
#.&lt;..&lt;&lt;#
#&gt;v.&gt;&lt;&gt;#
#&lt;^v^^&gt;#
######.#
</code></pre>
<p>Your expedition begins in the only non-wall position in the top row and needs to reach the only non-wall position in the bottom row. On each minute, you can <em>move</em> up, down, left, or right, or you can <em>wait</em> in place. You and the blizzards act <em>simultaneously</em>, and you cannot share a position with a blizzard.</p>
<p>In the above example, the fastest way to reach your goal requires <code><em>18</em></code> steps. Drawing the position of the expedition as <code>E</code>, one way to achieve this is:</p>
<pre><code>Initial state:
#<em>E</em>######
#&gt;&gt;.&lt;^&lt;#
#.&lt;..&lt;&lt;#
#&gt;v.&gt;&lt;&gt;#
#&lt;^v^^&gt;#
######.#
Minute 1, move down:
#.######
#<em>E</em>&gt;3.&lt;.#
#&lt;..&lt;&lt;.#
#&gt;2.22.#
#&gt;v..^&lt;#
######.#
Minute 2, move down:
#.######
#.2&gt;2..#
#<em>E</em>^22^&lt;#
#.&gt;2.^&gt;#
#.&gt;..&lt;.#
######.#
Minute 3, wait:
#.######
#&lt;^&lt;22.#
#<em>E</em>2&lt;.2.#
#&gt;&lt;2&gt;..#
#..&gt;&lt;..#
######.#
Minute 4, move up:
#.######
#<em>E</em>&lt;..22#
#&lt;&lt;.&lt;..#
#&lt;2.&gt;&gt;.#
#.^22^.#
######.#
Minute 5, move right:
#.######
#2<em>E</em>v.&lt;&gt;#
#&lt;.&lt;..&lt;#
#.^&gt;^22#
#.2..2.#
######.#
Minute 6, move right:
#.######
#&gt;2<em>E</em>&lt;.&lt;#
#.2v^2&lt;#
#&gt;..&gt;2&gt;#
#&lt;....&gt;#
######.#
Minute 7, move down:
#.######
#.22^2.#
#&lt;v<em>E</em>&lt;2.#
#&gt;&gt;v&lt;&gt;.#
#&gt;....&lt;#
######.#
Minute 8, move left:
#.######
#.&lt;&gt;2^.#
#.<em>E</em>&lt;&lt;.&lt;#
#.22..&gt;#
#.2v^2.#
######.#
Minute 9, move up:
#.######
#&lt;<em>E</em>2&gt;&gt;.#
#.&lt;&lt;.&lt;.#
#&gt;2&gt;2^.#
#.v&gt;&lt;^.#
######.#
Minute 10, move right:
#.######
#.2<em>E</em>.&gt;2#
#&lt;2v2^.#
#&lt;&gt;.&gt;2.#
#..&lt;&gt;..#
######.#
Minute 11, wait:
#.######
#2^<em>E</em>^2&gt;#
#&lt;v&lt;.^&lt;#
#..2.&gt;2#
#.&lt;..&gt;.#
######.#
Minute 12, move down:
#.######
#&gt;&gt;.&lt;^&lt;#
#.&lt;<em>E</em>.&lt;&lt;#
#&gt;v.&gt;&lt;&gt;#
#&lt;^v^^&gt;#
######.#
Minute 13, move down:
#.######
#.&gt;3.&lt;.#
#&lt;..&lt;&lt;.#
#&gt;2<em>E</em>22.#
#&gt;v..^&lt;#
######.#
Minute 14, move right:
#.######
#.2&gt;2..#
#.^22^&lt;#
#.&gt;2<em>E</em>^&gt;#
#.&gt;..&lt;.#
######.#
Minute 15, move right:
#.######
#&lt;^&lt;22.#
#.2&lt;.2.#
#&gt;&lt;2&gt;<em>E</em>.#
#..&gt;&lt;..#
######.#
Minute 16, move right:
#.######
#.&lt;..22#
#&lt;&lt;.&lt;..#
#&lt;2.&gt;&gt;<em>E</em>#
#.^22^.#
######.#
Minute 17, move down:
#.######
#2.v.&lt;&gt;#
#&lt;.&lt;..&lt;#
#.^&gt;^22#
#.2..2<em>E</em>#
######.#
Minute 18, move down:
#.######
#&gt;2.&lt;.&lt;#
#.2v^2&lt;#
#&gt;..&gt;2&gt;#
#&lt;....&gt;#
######<em>E</em>#
</code></pre>
<p><em>What is the fewest number of minutes required to avoid the blizzards and reach the goal?</em></p>
+118 -1
View File
@@ -1 +1,118 @@
Paste any inputs into this file. 121=0=-
1==02020022=
1==2==20--2==
1-11-
1==02=2=02=-1-00-=0
1011=-=--00
22-1-1=0--0=
1-=121-00=
1=1=-=10====10
1=-=-21002-2=--
211-2=2=-
1=-1=10
11221
2-21-20
1-0-
12221=0-0-1=
101-022121111-
11=01-==0211
1-2-00-=--11
1=-12=-=-2=1==02
1=-0111===202
20011
2=22
1=2=12-===-=
202=-2201=-2=
2=-0221
10=20-=2=--
1=01202=
202
12211=222=
2=1=1-0211-=0=
1-10
112=211112
11==-100-
1=21220=-122--2-2-
11-220
122=1110220==1
1=1-2210-21-=120102
1=0202=1=
11=2100==2-21121
2-21-=
2=00210-
1==--2
1-
1==
1220-1=22-=
1=1-==21021-=10
2=02=02000==1-
1--210-0-0
12-200==1=0-2=-0-
12110-020-2-1--
1-2
20=2=--12=120
112=20201
1=021-0-=2---
21202--1=-1=2--
101=
22=0---=-
21
10-1020
12=2-==-0-=12=000=
1-212-
200=1--0120=2==201
200-
2=0
1-1=1110211
1---1==2
1-2122==10--=0=10
1=0-0-2-=01-=220
2-0==00001002-=
1-0--0001-2=0=0-
1-02--01=-1
1=101121=0110021-
22-22===0-2
1=-0-----202=212201
120-00--10-=202=
1=00==
111022--0012=
11-2-0=01-=-02
1-011=-2
2=021-=--1
1--212000-2
1=-000-
1-=-==0
20=0012110
12=21-1-0
1=0021=1010=0=2
11-0-==01002
1102-20=-
102
12122
1-100121=
12=-1==20=20=20222
1-=-00--0--1-
1===-22-2201=01-=-2
1==0-11--==2=21=1-=1
20=0=20-110-1201-=2
112
22=-
2=2-2021
11100=
211-
10000==10-000--0
12
1-1---1=111=
11=-=102===-1-1=-
20210-2-2-==11
1012
1-0=-121==-0
1===0-0=-0=-=210
12--1-2---021=-=
1000
2-2011-
1--201001=002
2--
1---102=2=10110
1=0=2=011-=
12=--2-=1-0
+72 -1
View File
@@ -1 +1,72 @@
# Day 25 Puzzle Text.
<article class="day-desc"><h2>--- Day 25: Full of Hot Air ---</h2><p>As the expedition finally reaches the extraction point, several large <a href="https://en.wikipedia.org/wiki/Hot_air_balloon" target="_blank">hot air balloons</a> drift down to meet you. Crews quickly start unloading the equipment the balloons brought: many hot air balloon kits, some fuel tanks, and a <em>fuel heating machine</em>.</p>
<p>The fuel heating machine is a new addition to the process. When this mountain was a volcano, the ambient temperature was more reasonable; now, it's so cold that the fuel won't work at all without being warmed up first.</p>
<p>The Elves, seemingly in an attempt to make the new machine feel welcome, have already attached a pair of <a href="https://en.wikipedia.org/wiki/Googly_eyes" target="_blank">googly eyes</a> and started calling it "Bob".</p>
<p>To heat the fuel, Bob needs to know the total amount of fuel that will be processed ahead of time so it can correctly calibrate heat output and flow rate. This amount is simply the <em>sum</em> of the fuel requirements of all of the hot air balloons, and those fuel requirements are even listed clearly on the side of each hot air balloon's burner.</p>
<p>You assume the Elves will have no trouble adding up some numbers and are about to go back to figuring out which balloon is yours when you get a tap on the shoulder. Apparently, the fuel requirements use numbers written in a format the Elves don't recognize; predictably, they'd like your help deciphering them.</p>
<p>You make a list of all of the fuel requirements (your puzzle input), but you don't recognize the number format either. For example:</p>
<pre><code>1=-0-2
12111
2=0=
21
2=01
111
20012
112
1=-1=
1-12
12
1=
122
</code></pre>
<p>Fortunately, Bob is labeled with a support phone number. Not to be deterred, you call and ask for help.</p>
<p>"That's right, just supply the fuel amount to the-- oh, for more than one burner? No problem, you just need to add together our Special Numeral-Analogue Fuel Units. Patent pending! They're way better than normal numbers for--"</p>
<p>You mention that it's quite cold up here and ask if they can skip ahead.</p>
<p>"Okay, our Special Numeral-Analogue Fuel Units - SNAFU for short - are sort of like normal numbers. You know how starting on the right, normal numbers have a ones place, a tens place, a hundreds place, and so on, where the digit in each place tells you how many of that value you have?"</p>
<p>"SNAFU works the same way, except it uses powers of five instead of ten. Starting from the right, you have a ones place, a fives place, a twenty-fives place, a one-hundred-and-twenty-fives place, and so on. It's that easy!"</p>
<p>You ask why some of the digits look like <code>-</code> or <code>=</code> instead of "digits".</p>
<p>"You know, I never did ask the engineers why they did that. Instead of using digits four through zero, the digits are <code><em>2</em></code>, <code><em>1</em></code>, <code><em>0</em></code>, <em>minus</em> (written <code>-</code>), and <em>double-minus</em> (written <code>=</code>). Minus is worth -1, and double-minus is worth -2."</p>
<p>"So, because ten (in normal numbers) is two fives and no ones, in SNAFU it is written <code>20</code>. Since eight (in normal numbers) is two fives minus two ones, it is written <code>2=</code>."</p>
<p>"You can do it the other direction, too. Say you have the SNAFU number <code>2=-01</code>. That's <code>2</code> in the 625s place, <code>=</code> (double-minus) in the 125s place, <code>-</code> (minus) in the 25s place, <code>0</code> in the 5s place, and <code>1</code> in the 1s place. (2 times 625) plus (-2 times 125) plus (-1 times 25) plus (0 times 5) plus (1 times 1). That's 1250 plus -250 plus -25 plus 0 plus 1. <em>976</em>!"</p>
<p>"I see here that you're connected via our premium uplink service, so I'll transmit our handy SNAFU brochure to you now. Did you need anything else?"</p>
<p>You ask if the fuel will even work in these temperatures.</p>
<p>"Wait, it's <em>how</em> cold? There's no <em>way</em> the fuel - or <em>any</em> fuel - would work in those conditions! There are only a few places in the-- where did you say you are again?"</p>
<p>Just then, you notice one of the Elves pour a few drops from a snowflake-shaped container into one of the fuel tanks, thank the support representative for their time, and disconnect the call.</p>
<p>The SNAFU brochure contains a few more examples of decimal ("normal") numbers and their SNAFU counterparts:</p>
<pre><code> Decimal SNAFU
1 1
2 2
3 1=
4 1-
5 10
6 11
7 12
8 2=
9 2-
10 20
15 1=0
20 1-0
2022 1=11-2
12345 1-0---0
314159265 1121-1110-1=0
</code></pre>
<p>Based on this process, the SNAFU numbers in the example above can be converted to decimal numbers as follows:</p>
<pre><code> SNAFU Decimal
1=-0-2 1747
12111 906
2=0= 198
21 11
2=01 201
111 31
20012 1257
112 32
1=-1= 353
1-12 107
12 7
1= 3
122 37
</code></pre>
<p>In decimal, the sum of these numbers is <code>4890</code>.</p>
<p>As you go to input this number on Bob's console, you discover that some buttons you expected are missing. Instead, you are met with buttons labeled <code>=</code>, <code>-</code>, <code>0</code>, <code>1</code>, and <code>2</code>. Bob needs the input value expressed as a SNAFU number, not in decimal.</p>
<p>Reversing the process, you can determine that for the decimal number <code>4890</code>, the SNAFU number you need to supply to Bob's console is <code><em>2=-1=0</em></code>.</p>
<p>The Elves are starting to get cold. <em>What SNAFU number do you supply to Bob's console?</em></p>
+99 -1
View File
@@ -1 +1,99 @@
Paste any inputs into this file. 011112220220323233332231343014141131140112421211413355234334024414242133303312210313023000021220102
221002103112233201234202003421134043024153515443332415451142151141323114321301434333033210022221022
201200003311133331441214403131041312551423522332422531524232533513033233434420203421023110323221022
121121213131010131201002413232224444334133213322251443153145222321552044232113011214212110102102211
212113303331021314321111140111522454555135544314235452234224545142541330223322222234211031300120220
010212031223201244112200401335253221225255255322553133211323513113422143522323420011223321133113101
011020312301013040344114333334442144514455512552221415123255124524531151554104224200443112211210031
212103301320231332441144214355422451145143521345255326544451431544214432121550112030101122302303021
220232122110131143411335344551322314153422353555245353522346615142142533512423212340133002223102320
123203222223430330030314515252515255254362252265436645524643534633245232434155413030142133001200320
232211213322123322103442125511131155663325635553522434545445552266442151514322444424100420020000011
321232322313243000453341414523445426226644644265452262664344634465246122122543132514120020411332033
202331334121420235323225354242425245652324266442344526232654535245252651555215135125041401014413003
030112100334314051222325325124636325444634664346624462255253366255466452513431325251113413144442330
020200433043320152232154136232564443545365465255646653263522363554354564422421324241211021000140121
032011132023104255151145246424353264523526344436554334475646444542435562556325335443513020140421120
210204303043241221415453653453366254565373457364675545654666377423454542265263342335255230433142310
210312323220343143353556243436325432556736764666334633457533745332644345623536221544225432033020410
233410214315423344423442656226454445357767646343373565363645755734732354353645223242442442112322443
322403301001251255154242326443445466736576466455545656643435677365674243235222245343143455320114330
232343201234134131134332335444557474363474446344776366756565574535744735324323246532552555432040041
221232224415533122543465364445435364564576534743763474566355767775774577553544653464142513144443313
122112442244542214262445665475477545734565457478857667547473567477336557726442444644441243444402330
143012145515212424235524535555733334457686447444847564554866735433374643763343245542354341522310301
343034021325435535455442355474677535777784688864647648684444458747443667643423643452544435114443124
000403451411241463226443476733365546877644754747566667486574544543776475363624545332334511311214303
013002242525556352626433636455377384766855876756685885854848875568474373437675532433635212321111322
101010142252123346235437467476546685846885866865567487856755684744544675575633223264225545223542222
342002313434136635656244356646468576664565586756447555664585478665556463354555546643556622525525002
304211422335342355323755634454757484685568785668995686856577754577844777634756472362366633324314412
231133244553256623647336646666864756787445877675585597686594886667647464354533657554554353332112524
120344321215652622227445664658856658787585889889659567969656785855874777755473764556264244443152242
440423214313632526376434563658657485749798857588556576776776858587648478466464663564663336325425331
011254331316253653674574346456874647667888866559779658686765656768765578865554674352333225544221323
023413144524364645635675736677586666956885689798886598595799575656874764865373535644332466511331341
122254414355225323664755365568758589577679686887799795759896779887545576777454544375265466443443235
412421452563253445537467347658777879785759567968966967575558955868854646578873575357565236511122521
015221314664564236645543668766675798567999788879796666869699657885985874547845773566464625361212125
213255112624445653744634755467766595886577869989896967967796599685695675888763355455363352561531455
051115255524443264764435668448576976667776669978668998866669987997588887564444673776525636555252522
315344432555344664633555485554469988678878999897687977797786889787978545858784436346566536662543432
342334532442256655765436787556789957565686789788896899987689678797579887867778443435552454223234514
044222226353425754474346685474575657758678966697998869888679776868568567678584464343643446543142315
144512246654532464343347645766565789898698789788997968679687989758869974574466636667665323253213321
154415255624566636654388858668758665689978996897979798788878699767976598455446474765435324456113342
222333513555245346467374666655885657577998667798797888978998868866957797665858765377465234256133231
345551444536645634576788887678768556687766667898989777979999976777866956665855476574554565645424315
214425354332335634336444556745876659867688868787798798879898768996785655575686846567542442554353234
411151526365526435763654766745695769989997787877899999777677796975768665578855433353537425364324435
522535522334266753767645655578787759999797977799978897877967869699787686678555733446763633345235242
434554556234464756756646566577685856698867888798779989897888768886756666848455565474773255436431353
442445343526335577465554675665559886897887778777987888778968877985997667668778573677767566543431434
211451552626333634363465768567858685978899767778888797787769889997886696648488453374457335426324331
352321245665435473457546867457579566688987988898999788977968676875958875756786856557334623665613554
134251534254346364373746868447957667578688897887888977799998977767868758754674643636734354455334533
245245423445544557373667445675755587897766677987799879977688696665989986846448873477364262625234454
145224324344246776343755754785995768789786888699787788766886767677965697467477553656766544246513254
324145213325563543644657785454865677777876788869778868797668787676695555668476343574675463435354251
413445215463653557663646785857989685956686966678678698889778897766895898544664356673734242234254124
034351535553342544655674756865698875897888787897688768789698799656958666567856653353444644544544421
133431555226353336664734658784788759769799696889799686678886856966568675647876755663336364665314322
352533334635454546743545675475565978755677998676889876879868566868875574457747644333625466224445225
355351222554253337357543454756675876989667686867777777888979575678967457886686766643322426625255125
301424431256355654573454748776556985989986569888688898788856597696575488864856754567355352241115321
334321351343534467436553584585445758875669977678797666578677575578655877475477536443424544521454224
013544235464335336476633477774477476686866559855687876665969679665764854667467373455335366315243233
112151451535653464334745366774754847778758859698679755768697858997878486758757546343322225255512514
443545411335354445544673335765684574789589677978989757787667778688476787477664364445336662115531221
443244544145445266247734664546768464658669796775859668897565658658468857653377655436433366414135313
010252534423256334446667573476457575487596776895885755586667884466654888463534655556544243135421414
014442551411344322466653454757848477584476886899967686787665786647774457465756356452536324535435123
334422335251334244533574565465486878485446665569659976696474654844488654654664446434222541455145113
422042222114544645653646637673357446446767657686784455466855674884758555555655725563322345443214311
402101351333342265545553643374447487578876487756686755567778855457564663644744556325335113252214413
020401432452525465462342675634576768765558475768546747458444657465736777435756524535423151534540433
243400241421422365236324343433537655646765656686868457744888876887645466644353552522561443452110131
003103135121351256222624237444364336577744656885555668476484458534564557546523454435651431352134341
442201144132352152442423554634347545537756888457774564788446865557333633753246362522533121322124221
042304405522541234526265624675463537343637577754484575664343357636766467765454625421455125252421130
314110031551545454255523645535756377673434677564574657764673676766535556624242334545542323234044343
041012332333325345165432634364576475755744555334564654644333744353563644464423523312312411403444121
124302121131253134543646522633333333576373775465555676773747353674453633545332653355411213114300403
302411422212352135214225645652536667357533357667635654377766436757352425435362534153522532340243120
203202223241334312122414443425254534435347434576567673567635537464322534362435145114215322422004201
110342140441034112531143666254342264344435346667664677454757336354363455622352232125251133310231303
300304343314324221532432445663443563562366357346443374734472246525566435265232524142512222034111133
202233112212120515131252235262346544266665653664554636565424424235234433226241324545132240232410001
332313111224211043414543212336356265244525555535245664242355426664325225354122332125233004041231313
212202242323141205314235551145533455663632653424353364426426265425636324111513154352142322133233021
222001223102021231253525543223522653656656533626646546323265643636332221114125535230342011132023003
131321002042102021303551143221352255263646432525653222536364426366255225412113334103102433030120120
123013232113443113004333513541141433446563565453423353632226246342532522253511543223024330220123232
020100001122004013021214144132214525141333344452225255633226351331523254423535242210042134110021313
000032312330431022234112313521113225332255235165644226445131125441512142114320042430310221111210323
222131320213212322000341013532113515512425422422531545412311135522225313553330241403034233001021201
102232032332111012030031433325455242543415353325354325411434155351223114403024214003424030023121101
001023120230001141401143210134432545451343542414432432444534422135454111411010334001323200230022022
020210023322210014243401240134314541235251513215515342432345433232312001040222232101223203330221220
022010220332323232024402340343441321225445453325151544211235521343432303124012101020011220000301222
+24 -1
View File
@@ -1 +1,24 @@
# Day 8 Puzzle Text.
<article class="day-desc"><h2>--- Day 8: Treetop Tree House ---</h2><p>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 <a href="https://en.wikipedia.org/wiki/Tree_house" target="_blank">tree house</a>.</p>
<p>First, determine whether there is enough tree cover here to keep a tree house <em>hidden</em>. To do this, you need to count the number of trees that are <em>visible from outside the grid</em> when looking directly along a row or column.</p>
<p>The Elves have already launched a <a href="https://en.wikipedia.org/wiki/Quadcopter" target="_blank">quadcopter</a> to generate a map with the height of each tree (<span title="The Elves have already launched a quadcopter (your puzzle input).">your puzzle input</span>). For example:</p>
<pre><code>30373
25512
65332
33549
35390
</code></pre>
<p>Each tree is represented as a single digit whose value is its height, where <code>0</code> is the shortest and <code>9</code> is the tallest.</p>
<p>A tree is <em>visible</em> if all of the other trees between it and an edge of the grid are <em>shorter</em> than it. Only consider trees in the same row or column; that is, only look up, down, left, or right from any given tree.</p>
<p>All of the trees around the edge of the grid are <em>visible</em> - since they are already on the edge, there are no trees to block the view. In this example, that only leaves the <em>interior nine trees</em> to consider:</p>
<ul>
<li>The top-left <code>5</code> is <em>visible</em> from the left and top. (It isn't visible from the right or bottom since other trees of height <code>5</code> are in the way.)</li>
<li>The top-middle <code>5</code> is <em>visible</em> from the top and right.</li>
<li>The top-right <code>1</code> is not visible from any direction; for it to be visible, there would need to only be trees of height <em>0</em> between it and an edge.</li>
<li>The left-middle <code>5</code> is <em>visible</em>, but only from the right.</li>
<li>The center <code>3</code> is not visible from any direction; for it to be visible, there would need to be only trees of at most height <code>2</code> between it and an edge.</li>
<li>The right-middle <code>3</code> is <em>visible</em> from the right.</li>
<li>In the bottom row, the middle <code>5</code> is <em>visible</em>, but the <code>3</code> and <code>4</code> are not.</li>
</ul>
<p>With 16 trees visible on the edge and another 5 visible in the interior, a total of <code><em>21</em></code> trees are visible in this arrangement.</p>
<p>Consider your map; <em>how many trees are visible from outside the grid?</em></p>
+2000 -1
View File
File diff suppressed because it is too large Load Diff
+233 -1
View File
@@ -1 +1,233 @@
# Day 9 Puzzle Text.
<article class="day-desc"><h2>--- Day 9: Rope Bridge ---</h2><p>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.</p>
<p>It seems to support the Elves just fine, though. The bridge spans a gorge which was carved out by the massive river far below you.</p>
<p>You step carefully; as you do, the ropes stretch and twist. You decide to distract yourself by modeling rope physics; maybe you can even figure out where <em>not</em> to step.</p>
<p>Consider a rope with a knot at each end; these knots mark the <em>head</em> and the <em>tail</em> of the rope. If the head moves far enough away from the tail, the tail is pulled toward the head.</p>
<p>Due to nebulous reasoning involving <a href="https://en.wikipedia.org/wiki/Planck_units#Planck_length" target="_blank">Planck lengths</a>, you should be able to model the positions of the knots on a two-dimensional grid. Then, by following a hypothetical <em>series of motions</em> (your puzzle input) for the head, you can determine how the tail will move.</p>
<p><span title="I'm an engineer, not a physicist!">Due to the aforementioned Planck lengths</span>, the rope must be quite short; in fact, the head (<code>H</code>) and tail (<code>T</code>) must <em>always be touching</em> (diagonally adjacent and even overlapping both count as touching):</p>
<pre><code>....
.TH.
....
....
.H..
..T.
....
...
.H. (H covers T)
...
</code></pre>
<p>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:</p>
<pre><code>..... ..... .....
.TH.. -&gt; .T.H. -&gt; ..TH.
..... ..... .....
... ... ...
.T. .T. ...
.H. -&gt; ... -&gt; .T.
... .H. .H.
... ... ...
</code></pre>
<p>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:</p>
<pre><code>..... ..... .....
..... ..H.. ..H..
..H.. -&gt; ..... -&gt; ..T..
.T... .T... .....
..... ..... .....
..... ..... .....
..... ..... .....
..H.. -&gt; ...H. -&gt; ..TH.
.T... .T... .....
..... ..... .....
</code></pre>
<p>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.</p>
<p>For example:</p>
<pre><code>R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2
</code></pre>
<p>This series of motions moves the head <em>right</em> four steps, then <em>up</em> four steps, then <em>left</em> three steps, then <em>down</em> 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 (<code>s</code> marks the starting position as a reference point):</p>
<pre><code>== Initial State ==
......
......
......
......
H..... (H covers T, s)
== R 4 ==
......
......
......
......
TH.... (T covers s)
......
......
......
......
sTH...
......
......
......
......
s.TH..
......
......
......
......
s..TH.
== U 4 ==
......
......
......
....H.
s..T..
......
......
....H.
....T.
s.....
......
....H.
....T.
......
s.....
....H.
....T.
......
......
s.....
== L 3 ==
...H..
....T.
......
......
s.....
..HT..
......
......
......
s.....
.HT...
......
......
......
s.....
== D 1 ==
..T...
.H....
......
......
s.....
== R 4 ==
..T...
..H...
......
......
s.....
..T...
...H..
......
......
s.....
......
...TH.
......
......
s.....
......
....TH
......
......
s.....
== D 1 ==
......
....T.
.....H
......
s.....
== L 5 ==
......
....T.
....H.
......
s.....
......
....T.
...H..
......
s.....
......
......
..HT..
......
s.....
......
......
.HT...
......
s.....
......
......
HT....
......
s.....
== R 2 ==
......
......
.H.... (H covers T)
......
s.....
......
......
.TH...
......
s.....
</code></pre>
<p>After simulating the rope, you can count up all of the positions the <em>tail visited at least once</em>. In this diagram, <code>s</code> again marks the starting position (which the tail also visited) and <code>#</code> marks other positions the tail visited:</p>
<pre><code>..##..
...##.
.####.
....#.
s###..
</code></pre>
<p>So, there are <code><em>13</em></code> positions the tail visited at least once.</p>
<p>Simulate your complete hypothetical series of motions. <em>How many positions does the tail of the rope visit at least once?</em></p>