master
parent f1bd9923cb
commit 655fafd37f
13 changed files with 2208 additions and 0 deletions

#### 78 2019/day13/problem 100644 View File

 `@ -0,0 +1,78 @@` `Advent of Code` ``` ``` `--- Day 13: Care Package ---` ``` ``` ` As you ponder the solitude of space and the ever-increasing three-hour roundtrip for messages between you and Earth, you` ` notice that the Space Mail Indicator Light is blinking. To help keep you sane, the Elves have sent you a care package.` ``` ``` ` It's a new game for the ship's arcade cabinet! Unfortunately, the arcade is all the way on the other end of the ship. Surely,` ` it won't be hard to build your own - the care package even comes with schematics.` ``` ``` ` The arcade cabinet runs Intcode software like the game the Elves sent (your puzzle input). It has a primitive screen capable` ` of drawing square tiles on a grid. The software draws tiles to the screen with output instructions: every three output` ` instructions specify the x position (distance from the left), y position (distance from the top), and tile id. The tile id is` ` interpreted as follows:` ``` ``` ` • 0 is an empty tile. No game object appears in this tile.` ` • 1 is a wall tile. Walls are indestructible barriers.` ` • 2 is a block tile. Blocks can be broken by the ball.` ` • 3 is a horizontal paddle tile. The paddle is indestructible.` ` • 4 is a ball tile. The ball moves diagonally and bounces off objects.` ``` ``` ` For example, a sequence of output values like 1,2,3,6,5,4 would draw a horizontal paddle tile (1 tile from the left and 2` ` tiles from the top) and a ball tile (6 tiles from the left and 5 tiles from the top).` ``` ``` ` Start the game. How many block tiles are on the screen when the game exits?` ``` ``` ` Your puzzle answer was 284.` ``` ``` `--- Part Two ---` ``` ``` ` The game didn't run because you didn't put in any quarters. Unfortunately, you did not bring any quarters. Memory address 0` ` represents the number of quarters that have been inserted; set it to 2 to play for free.` ``` ``` ` The arcade cabinet has a joystick that can move left and right. The software reads the position of the joystick with input` ` instructions:` ``` ``` ` • If the joystick is in the neutral position, provide 0.` ` • If the joystick is tilted to the left, provide -1.` ` • If the joystick is tilted to the right, provide 1.` ``` ``` ` The arcade cabinet also has a segment display capable of showing a single number that represents the player's current score.` ` When three output instructions specify X=-1, Y=0, the third output instruction is not a tile; the value instead specifies the` ` new score to show in the segment display. For example, a sequence of output values like -1,0,12345 would show 12345 as the` ` player's current score.` ``` ``` ` Beat the game by breaking all the blocks. What is your score after the last block is broken?` ``` ``` ` Your puzzle answer was 13581.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Arcade_cabinet` ` . https://adventofcode.com/2019/day/9` ` . https://en.wikipedia.org/wiki/Joystick` ` . https://en.wikipedia.org/wiki/Display_device#Segment_displays` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/13/input`

#### 148 2019/day14/problem 100644 View File

 `@ -0,0 +1,148 @@` `Advent of Code` ``` ``` `--- Day 14: Space Stoichiometry ---` ``` ``` ` As you approach the rings of Saturn, your ship's low fuel indicator turns on. There isn't any fuel here, but the rings have` ` plenty of raw material. Perhaps your ship's Inter-Stellar Refinery Union brand nanofactory can turn these raw materials into` ` fuel.` ``` ``` ` You ask the nanofactory to produce a list of the reactions it can perform that are relevant to this process (your puzzle` ` input). Every reaction turns some quantities of specific input chemicals into some quantity of an output chemical. Almost` ` every chemical is produced by exactly one reaction; the only exception, ORE, is the raw material input to the entire process` ` and is not produced by a reaction.` ``` ``` ` You just need to know how much ORE you'll need to collect before you can produce one unit of FUEL.` ``` ``` ` Each reaction gives specific quantities for its inputs and output; reactions cannot be partially run, so only whole integer` ` multiples of these quantities can be used. (It's okay to have leftover chemicals when you're done, though.) For example, the` ` reaction 1 A, 2 B, 3 C => 2 D means that exactly 2 units of chemical D can be produced by consuming exactly 1 A, 2 B and 3 C.` ` You can run the full reaction as many times as necessary; for example, you could produce 10 D by consuming 5 A, 10 B, and 15` ` C.` ``` ``` ` Suppose your nanofactory produces the following list of reactions:` ``` ``` ` 10 ORE => 10 A` ` 1 ORE => 1 B` ` 7 A, 1 B => 1 C` ` 7 A, 1 C => 1 D` ` 7 A, 1 D => 1 E` ` 7 A, 1 E => 1 FUEL` ``` ``` ` The first two reactions use only ORE as inputs; they indicate that you can produce as much of chemical A as you want (in` ` increments of 10 units, each 10 costing 10 ORE) and as much of chemical B as you want (each costing 1 ORE). To produce 1` ` FUEL, a total of 31 ORE is required: 1 ORE to produce 1 B, then 30 more ORE to produce the 7 + 7 + 7 + 7 = 28 A (with 2 extra` ` A wasted) required in the reactions to convert the B into C, C into D, D into E, and finally E into FUEL. (30 A is produced` ` because its reaction requires that it is created in increments of 10.)` ``` ``` ` Or, suppose you have the following list of reactions:` ``` ``` ` 9 ORE => 2 A` ` 8 ORE => 3 B` ` 7 ORE => 5 C` ` 3 A, 4 B => 1 AB` ` 5 B, 7 C => 1 BC` ` 4 C, 1 A => 1 CA` ` 2 AB, 3 BC, 4 CA => 1 FUEL` ``` ``` ` The above list of reactions requires 165 ORE to produce 1 FUEL:` ``` ``` ` • Consume 45 ORE to produce 10 A.` ` • Consume 64 ORE to produce 24 B.` ` • Consume 56 ORE to produce 40 C.` ` • Consume 6 A, 8 B to produce 2 AB.` ` • Consume 15 B, 21 C to produce 3 BC.` ` • Consume 16 C, 4 A to produce 4 CA.` ` • Consume 2 AB, 3 BC, 4 CA to produce 1 FUEL.` ``` ``` ` Here are some larger examples:` ``` ``` ` • 13312 ORE for 1 FUEL:` ``` ``` ` 157 ORE => 5 NZVS` ` 165 ORE => 6 DCFZ` ` 44 XJWVT, 5 KHKGT, 1 QDVJ, 29 NZVS, 9 GPVTF, 48 HKGWZ => 1 FUEL` ` 12 HKGWZ, 1 GPVTF, 8 PSHF => 9 QDVJ` ` 179 ORE => 7 PSHF` ` 177 ORE => 5 HKGWZ` ` 7 DCFZ, 7 PSHF => 2 XJWVT` ` 165 ORE => 2 GPVTF` ` 3 DCFZ, 7 NZVS, 5 HKGWZ, 10 PSHF => 8 KHKGT` ``` ``` ` • 180697 ORE for 1 FUEL:` ``` ``` ` 2 VPVL, 7 FWMGM, 2 CXFTF, 11 MNCFX => 1 STKFG` ` 17 NVRVD, 3 JNWZP => 8 VPVL` ` 53 STKFG, 6 MNCFX, 46 VJHF, 81 HVMC, 68 CXFTF, 25 GNMV => 1 FUEL` ` 22 VJHF, 37 MNCFX => 5 FWMGM` ` 139 ORE => 4 NVRVD` ` 144 ORE => 7 JNWZP` ` 5 MNCFX, 7 RFSQX, 2 FWMGM, 2 VPVL, 19 CXFTF => 3 HVMC` ` 5 VJHF, 7 MNCFX, 9 VPVL, 37 CXFTF => 6 GNMV` ` 145 ORE => 6 MNCFX` ` 1 NVRVD => 8 CXFTF` ` 1 VJHF, 6 MNCFX => 4 RFSQX` ` 176 ORE => 6 VJHF` ``` ``` ` • 2210736 ORE for 1 FUEL:` ``` ``` ` 171 ORE => 8 CNZTR` ` 7 ZLQW, 3 BMBT, 9 XCVML, 26 XMNCP, 1 WPTQ, 2 MZWV, 1 RJRHP => 4 PLWSL` ` 114 ORE => 4 BHXH` ` 14 VRPVC => 6 BMBT` ` 6 BHXH, 18 KTJDG, 12 WPTQ, 7 PLWSL, 31 FHTLT, 37 ZDVW => 1 FUEL` ` 6 WPTQ, 2 BMBT, 8 ZLQW, 18 KTJDG, 1 XMNCP, 6 MZWV, 1 RJRHP => 6 FHTLT` ` 15 XDBXC, 2 LTCX, 1 VRPVC => 6 ZLQW` ` 13 WPTQ, 10 LTCX, 3 RJRHP, 14 XMNCP, 2 MZWV, 1 ZLQW => 1 ZDVW` ` 5 BMBT => 4 WPTQ` ` 189 ORE => 9 KTJDG` ` 1 MZWV, 17 XDBXC, 3 XCVML => 2 XMNCP` ` 12 VRPVC, 27 CNZTR => 2 XDBXC` ` 15 KTJDG, 12 BHXH => 5 XCVML` ` 3 BHXH, 2 VRPVC => 7 MZWV` ` 121 ORE => 7 VRPVC` ` 7 XCVML => 6 RJRHP` ` 5 BHXH, 4 VRPVC => 5 LTCX` ``` ``` ` Given the list of reactions in your puzzle input, what is the minimum amount of ORE required to produce exactly 1 FUEL?` ``` ``` ` Your puzzle answer was 751038.` ``` ``` `--- Part Two ---` ``` ``` ` After collecting ORE for a while, you check your cargo hold: 1 trillion (1000000000000) units of ORE.` ``` ``` ` With that much ore, given the examples above:` ``` ``` ` • The 13312 ORE-per-FUEL example could produce 82892753 FUEL.` ` • The 180697 ORE-per-FUEL example could produce 5586022 FUEL.` ` • The 2210736 ORE-per-FUEL example could produce 460664 FUEL.` ``` ``` ` Given 1 trillion ORE, what is the maximum amount of FUEL you can produce?` ``` ``` ` Your puzzle answer was 2074843.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/14/input`

#### 173 2019/day15/problem 100644 View File

 `@ -0,0 +1,173 @@` `Advent of Code` ``` ``` `--- Day 15: Oxygen System ---` ``` ``` ` Out here in deep space, many things can go wrong. Fortunately, many of those things have indicator lights. Unfortunately, one` ` of those lights is lit: the oxygen system for part of the ship has failed!` ``` ``` ` According to the readouts, the oxygen system must have failed days ago after a rupture in oxygen tank two; that section of` ` the ship was automatically sealed once oxygen levels went dangerously low. A single remotely-operated repair droid is your` ` only option for fixing the oxygen system.` ``` ``` ` The Elves' care package included an Intcode program (your puzzle input) that you can use to remotely control the repair` ` droid. By running that program, you can direct the repair droid to the oxygen system and fix the problem.` ``` ``` ` The remote control program executes the following steps in a loop forever:` ``` ``` ` • Accept a movement command via an input instruction.` ` • Send the movement command to the repair droid.` ` • Wait for the repair droid to finish the movement operation.` ` • Report on the status of the repair droid via an output instruction.` ``` ``` ` Only four movement commands are understood: north (1), south (2), west (3), and east (4). Any other command is invalid. The` ` movements differ in direction, but not in distance: in a long enough east-west hallway, a series of commands like` ` 4,4,4,4,3,3,3,3 would leave the repair droid back where it started.` ``` ``` ` The repair droid can reply with any of the following status codes:` ``` ``` ` • 0: The repair droid hit a wall. Its position has not changed.` ` • 1: The repair droid has moved one step in the requested direction.` ` • 2: The repair droid has moved one step in the requested direction; its new position is the location of the oxygen system.` ``` ``` ` You don't know anything about the area around the repair droid, but you can figure it out by watching the status codes.` ``` ``` ` For example, we can draw the area using D for the droid, # for walls, . for locations the droid can traverse, and empty space` ` for unexplored locations. Then, the initial state looks like this:` ``` ``` ``` ``` ``` ``` ` D` ``` ``` ``` ``` ``` ``` ` To make the droid go north, send it 1. If it replies with 0, you know that location is a wall and that the droid didn't move:` ``` ``` ``` ``` ` #` ` D` ``` ``` ``` ``` ``` ``` ` To move east, send 4; a reply of 1 means the movement was successful:` ``` ``` ``` ``` ` #` ` .D` ``` ``` ``` ``` ``` ``` ` Then, perhaps attempts to move north (1), south (2), and east (4) are all met with replies of 0:` ``` ``` ``` ``` ` ##` ` .D#` ` #` ``` ``` ``` ``` ` Now, you know the repair droid is in a dead end. Backtrack with 3 (which you already know will get a reply of 1 because you` ` already know that location is open):` ``` ``` ``` ``` ` ##` ` D.#` ` #` ``` ``` ``` ``` ` Then, perhaps west (3) gets a reply of 0, south (2) gets a reply of 1, south again (2) gets a reply of 0, and then west (3)` ` gets a reply of 2:` ``` ``` ``` ``` ` ##` ` #..#` ` D.#` ` #` ``` ``` ` Now, because of the reply of 2, you know you've found the oxygen system! In this example, it was only 2 moves away from the` ` repair droid's starting position.` ``` ``` ` What is the fewest number of movement commands required to move the repair droid from its starting position to the location` ` of the oxygen system?` ``` ``` ` Your puzzle answer was 240.` ``` ``` `--- Part Two ---` ``` ``` ` You quickly repair the oxygen system; oxygen gradually fills the area.` ``` ``` ` Oxygen starts in the location containing the repaired oxygen system. It takes one minute for oxygen to spread to all open` ` locations that are adjacent to a location that already contains oxygen. Diagonal locations are not adjacent.` ``` ``` ` In the example above, suppose you've used the droid to explore the area fully and have the following map (where locations` ` that currently contain oxygen are marked O):` ``` ``` ` ##` ` #..##` ` #.#..#` ` #.O.#` ` ###` ``` ``` ` Initially, the only location which contains oxygen is the location of the repaired oxygen system. However, after one minute,` ` the oxygen spreads to all open (.) locations that are adjacent to a location containing oxygen:` ``` ``` ` ##` ` #..##` ` #.#..#` ` #OOO#` ` ###` ``` ``` ` After a total of two minutes, the map looks like this:` ``` ``` ` ##` ` #..##` ` #O#O.#` ` #OOO#` ` ###` ``` ``` ` After a total of three minutes:` ``` ``` ` ##` ` #O.##` ` #O#OO#` ` #OOO#` ` ###` ``` ``` ` And finally, the whole region is full of oxygen after a total of four minutes:` ``` ``` ` ##` ` #OO##` ` #O#OO#` ` #OOO#` ` ###` ``` ``` ` So, in this example, all locations contain oxygen after 4 minutes.` ``` ``` ` Use the repair droid to get a complete map of the area. How many minutes will it take to fill with oxygen?` ``` ``` ` Your puzzle answer was 322.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/day/9` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/15/input`

#### 143 2019/day16/problem 100644 View File

 `@ -0,0 +1,143 @@` `Advent of Code` ``` ``` `--- Day 16: Flawed Frequency Transmission ---` ``` ``` ` You're 3/4ths of the way through the gas giants. Not only do roundtrip signals to Earth take five hours, but the signal` ` quality is quite bad as well. You can clean up the signal with the Flawed Frequency Transmission algorithm, or FFT.` ``` ``` ` As input, FFT takes a list of numbers. In the signal you received (your puzzle input), each number is a single digit: data` ` like 15243 represents the sequence 1, 5, 2, 4, 3.` ``` ``` ` FFT operates in repeated phases. In each phase, a new list is constructed with the same length as the input list. This new` ` list is also used as the input for the next phase.` ``` ``` ` Each element in the new list is built by multiplying every value in the input list by a value in a repeating pattern and then` ` adding up the results. So, if the input list were 9, 8, 7, 6, 5 and the pattern for a given element were 1, 2, 3, the result` ` would be 9*1 + 8*2 + 7*3 + 6*1 + 5*2 (with each input element on the left and each value in the repeating pattern on the` ` right of each multiplication). Then, only the ones digit is kept: 38 becomes 8, -17 becomes 7, and so on.` ``` ``` ` While each element in the output array uses all of the same input array elements, the actual repeating pattern to use depends` ` on which output element is being calculated. The base pattern is 0, 1, 0, -1. Then, repeat each value in the pattern a number` ` of times equal to the position in the output list being considered. Repeat once for the first element, twice for the second` ` element, three times for the third element, and so on. So, if the third element of the output list is being calculated,` ` repeating the values would produce: 0, 0, 0, 1, 1, 1, 0, 0, 0, -1, -1, -1.` ``` ``` ` When applying the pattern, skip the very first value exactly once. (In other words, offset the whole pattern left by one.)` ` So, for the second element of the output list, the actual pattern used would be: 0, 1, 1, 0, 0, -1, -1, 0, 0, 1, 1, 0, 0, -1,` ` -1, ....` ``` ``` ` After using this process to calculate each element of the output list, the phase is complete, and the output list of this` ` phase is used as the new input list for the next phase, if any.` ``` ``` ` Given the input signal 12345678, below are four phases of FFT. Within each phase, each output digit is calculated on a single` ` line with the result at the far right; each multiplication operation shows the input digit on the left and the pattern value` ` on the right:` ``` ``` ` Input signal: 12345678` ``` ``` ` 1*1 + 2*0 + 3*-1 + 4*0 + 5*1 + 6*0 + 7*-1 + 8*0 = 4` ` 1*0 + 2*1 + 3*1 + 4*0 + 5*0 + 6*-1 + 7*-1 + 8*0 = 8` ` 1*0 + 2*0 + 3*1 + 4*1 + 5*1 + 6*0 + 7*0 + 8*0 = 2` ` 1*0 + 2*0 + 3*0 + 4*1 + 5*1 + 6*1 + 7*1 + 8*0 = 2` ` 1*0 + 2*0 + 3*0 + 4*0 + 5*1 + 6*1 + 7*1 + 8*1 = 6` ` 1*0 + 2*0 + 3*0 + 4*0 + 5*0 + 6*1 + 7*1 + 8*1 = 1` ` 1*0 + 2*0 + 3*0 + 4*0 + 5*0 + 6*0 + 7*1 + 8*1 = 5` ` 1*0 + 2*0 + 3*0 + 4*0 + 5*0 + 6*0 + 7*0 + 8*1 = 8` ``` ``` ` After 1 phase: 48226158` ``` ``` ` 4*1 + 8*0 + 2*-1 + 2*0 + 6*1 + 1*0 + 5*-1 + 8*0 = 3` ` 4*0 + 8*1 + 2*1 + 2*0 + 6*0 + 1*-1 + 5*-1 + 8*0 = 4` ` 4*0 + 8*0 + 2*1 + 2*1 + 6*1 + 1*0 + 5*0 + 8*0 = 0` ` 4*0 + 8*0 + 2*0 + 2*1 + 6*1 + 1*1 + 5*1 + 8*0 = 4` ` 4*0 + 8*0 + 2*0 + 2*0 + 6*1 + 1*1 + 5*1 + 8*1 = 0` ` 4*0 + 8*0 + 2*0 + 2*0 + 6*0 + 1*1 + 5*1 + 8*1 = 4` ` 4*0 + 8*0 + 2*0 + 2*0 + 6*0 + 1*0 + 5*1 + 8*1 = 3` ` 4*0 + 8*0 + 2*0 + 2*0 + 6*0 + 1*0 + 5*0 + 8*1 = 8` ``` ``` ` After 2 phases: 34040438` ``` ``` ` 3*1 + 4*0 + 0*-1 + 4*0 + 0*1 + 4*0 + 3*-1 + 8*0 = 0` ` 3*0 + 4*1 + 0*1 + 4*0 + 0*0 + 4*-1 + 3*-1 + 8*0 = 3` ` 3*0 + 4*0 + 0*1 + 4*1 + 0*1 + 4*0 + 3*0 + 8*0 = 4` ` 3*0 + 4*0 + 0*0 + 4*1 + 0*1 + 4*1 + 3*1 + 8*0 = 1` ` 3*0 + 4*0 + 0*0 + 4*0 + 0*1 + 4*1 + 3*1 + 8*1 = 5` ` 3*0 + 4*0 + 0*0 + 4*0 + 0*0 + 4*1 + 3*1 + 8*1 = 5` ` 3*0 + 4*0 + 0*0 + 4*0 + 0*0 + 4*0 + 3*1 + 8*1 = 1` ` 3*0 + 4*0 + 0*0 + 4*0 + 0*0 + 4*0 + 3*0 + 8*1 = 8` ``` ``` ` After 3 phases: 03415518` ``` ``` ` 0*1 + 3*0 + 4*-1 + 1*0 + 5*1 + 5*0 + 1*-1 + 8*0 = 0` ` 0*0 + 3*1 + 4*1 + 1*0 + 5*0 + 5*-1 + 1*-1 + 8*0 = 1` ` 0*0 + 3*0 + 4*1 + 1*1 + 5*1 + 5*0 + 1*0 + 8*0 = 0` ` 0*0 + 3*0 + 4*0 + 1*1 + 5*1 + 5*1 + 1*1 + 8*0 = 2` ` 0*0 + 3*0 + 4*0 + 1*0 + 5*1 + 5*1 + 1*1 + 8*1 = 9` ` 0*0 + 3*0 + 4*0 + 1*0 + 5*0 + 5*1 + 1*1 + 8*1 = 4` ` 0*0 + 3*0 + 4*0 + 1*0 + 5*0 + 5*0 + 1*1 + 8*1 = 9` ` 0*0 + 3*0 + 4*0 + 1*0 + 5*0 + 5*0 + 1*0 + 8*1 = 8` ``` ``` ` After 4 phases: 01029498` ``` ``` ` Here are the first eight digits of the final output list after 100 phases for some larger inputs:` ``` ``` ` • 80871224585914546619083218645595 becomes 24176176.` ` • 19617804207202209144916044189917 becomes 73745418.` ` • 69317163492948606335995924319873 becomes 52432133.` ``` ``` ` After 100 phases of FFT, what are the first eight digits in the final output list?` ``` ``` ` Your puzzle answer was 40921727.` ``` ``` `--- Part Two ---` ``` ``` ` Now that your FFT is working, you can decode the real signal.` ``` ``` ` The real signal is your puzzle input repeated 10000 times. Treat this new signal as a single input list. Patterns are still` ` calculated as before, and 100 phases of FFT are still applied.` ``` ``` ` The first seven digits of your initial input signal also represent the message offset. The message offset is the location of` ` the eight-digit message in the final output list. Specifically, the message offset indicates the number of digits to skip` ` before reading the eight-digit message. For example, if the first seven digits of your initial input signal were 1234567, the` ` eight-digit message would be the eight digits after skipping 1,234,567 digits of the final output list. Or, if the message` ` offset were 7 and your final output list were 98765432109876543210, the eight-digit message would be 21098765. (Of course,` ` your real message offset will be a seven-digit number, not a one-digit number like 7.)` ``` ``` ` Here is the eight-digit message in the final output list after 100 phases. The message offset given in each input has been` ` highlighted. (Note that the inputs given below are repeated 10000 times to find the actual starting input lists.)` ``` ``` ` • 03036732577212944063491565474664 becomes 84462026.` ` • 02935109699940807407585447034323 becomes 78725270.` ` • 03081770884921959731165446850517 becomes 53553731.` ``` ``` ` After repeating your input signal 10000 times and running 100 phases of FFT, what is the eight-digit message embedded in the` ` final output list?` ``` ``` ` Your puzzle answer was 89950138.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Gas_giant` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/16/input`

#### 192 2019/day17/problem 100644 View File

 `@ -0,0 +1,192 @@` `Advent of Code` ``` ``` `--- Day 17: Set and Forget ---` ``` ``` ` An early warning system detects an incoming solar flare and automatically activates the ship's electromagnetic shield.` ` Unfortunately, this has cut off the Wi-Fi for many small robots that, unaware of the impending danger, are now trapped on` ` exterior scaffolding on the unsafe side of the shield. To rescue them, you'll have to act quickly!` ``` ``` ` The only tools at your disposal are some wired cameras and a small vacuum robot currently asleep at its charging station. The` ` video quality is poor, but the vacuum robot has a needlessly bright LED that makes it easy to spot no matter where it is.` ``` ``` ` An Intcode program, the Aft Scaffolding Control and Information Interface (ASCII, your puzzle input), provides access to the` ` cameras and the vacuum robot. Currently, because the vacuum robot is asleep, you can only access the cameras.` ``` ``` ` Running the ASCII program on your Intcode computer will provide the current view of the scaffolds. This is output, purely` ` coincidentally, as ASCII code: 35 means #, 46 means ., 10 starts a new line of output below the current one, and so on.` ` (Within a line, characters are drawn left-to-right.)` ``` ``` ` In the camera output, # represents a scaffold and . represents open space. The vacuum robot is visible as ^, v, <, or >` ` depending on whether it is facing up, down, left, or right respectively. When drawn like this, the vacuum robot is always on` ` a scaffold; if the vacuum robot ever walks off of a scaffold and begins tumbling through space uncontrollably, it will` ` instead be visible as X.` ``` ``` ` In general, the scaffold forms a path, but it sometimes loops back onto itself. For example, suppose you can see the` ` following view from the cameras:` ``` ``` ` ..#..........` ` ..#..........` ` #######...###` ` #.#...#...#.#` ` #############` ` ..#...#...#..` ` ..#####...^..` ``` ``` ` Here, the vacuum robot, ^ is facing up and sitting at one end of the scaffold near the bottom-right of the image. The` ` scaffold continues up, loops across itself several times, and ends at the top-left of the image.` ``` ``` ` The first step is to calibrate the cameras by getting the alignment parameters of some well-defined points. Locate all` ` scaffold intersections; for each, its alignment parameter is the distance between its left edge and the left edge of the view` ` multiplied by the distance between its top edge and the top edge of the view. Here, the intersections from the above image` ` are marked O:` ``` ``` ` ..#..........` ` ..#..........` ` ##O####...###` ` #.#...#...#.#` ` ##O###O###O##` ` ..#...#...#..` ` ..#####...^..` ``` ``` ` For these intersections:` ``` ``` ` • The top-left intersection is 2 units from the left of the image and 2 units from the top of the image, so its alignment` ` parameter is 2 * 2 = 4.` ` • The bottom-left intersection is 2 units from the left and 4 units from the top, so its alignment parameter is 2 * 4 = 8.` ` • The bottom-middle intersection is 6 from the left and 4 from the top, so its alignment parameter is 24.` ` • The bottom-right intersection's alignment parameter is 40.` ``` ``` ` To calibrate the cameras, you need the sum of the alignment parameters. In the above example, this is 76.` ``` ``` ` Run your ASCII program. What is the sum of the alignment parameters for the scaffold intersections?` ``` ``` ` Your puzzle answer was 3336.` ``` ``` `--- Part Two ---` ``` ``` ` Now for the tricky part: notifying all the other robots about the solar flare. The vacuum robot can do this automatically if` ` it gets into range of a robot. However, you can't see the other robots on the camera, so you need to be thorough instead: you` ` need to make the vacuum robot visit every part of the scaffold at least once.` ``` ``` ` The vacuum robot normally wanders randomly, but there isn't time for that today. Instead, you can override its movement logic` ` with new rules.` ``` ``` ` Force the vacuum robot to wake up by changing the value in your ASCII program at address 0 from 1 to 2. When you do this, you` ` will be automatically prompted for the new movement rules that the vacuum robot should use. The ASCII program will use input` ` instructions to receive them, but they need to be provided as ASCII code; end each line of logic with a single newline, ASCII` ` code 10.` ``` ``` ` First, you will be prompted for the main movement routine. The main routine may only call the movement functions: A, B, or C.` ` Supply the movement functions to use as ASCII text, separating them with commas (,, ASCII code 44), and ending the list with` ` a newline (ASCII code 10). For example, to call A twice, then alternate between B and C three times, provide the string` ` A,A,B,C,B,C,B,C and then a newline.` ``` ``` ` Then, you will be prompted for each movement function. Movement functions may use L to turn left, R to turn right, or a` ` number to move forward that many units. Movement functions may not call other movement functions. Again, separate the actions` ` with commas and end the list with a newline. For example, to move forward 10 units, turn left, move forward 8 units, turn` ` right, and finally move forward 6 units, provide the string 10,L,8,R,6 and then a newline.` ``` ``` ` Finally, you will be asked whether you want to see a continuous video feed; provide either y or n and a newline. Enabling the` ` continuous video feed can help you see what's going on, but it also requires a significant amount of processing power, and` ` may even cause your Intcode computer to overheat.` ``` ``` ` Due to the limited amount of memory in the vacuum robot, the ASCII definitions of the main routine and the movement functions` ` may each contain at most 20 characters, not counting the newline.` ``` ``` ` For example, consider the following camera feed:` ``` ``` ` #######...#####` ` #.....#...#...#` ` #.....#...#...#` ` ......#...#...#` ` ......#...###.#` ` ......#.....#.#` ` ^########...#.#` ` ......#.#...#.#` ` ......#########` ` ........#...#..` ` ....#########..` ` ....#...#......` ` ....#...#......` ` ....#...#......` ` ....#####......` ``` ``` ` In order for the vacuum robot to visit every part of the scaffold at least once, one path it could take is:` ``` ``` ` R,8,R,8,R,4,R,4,R,8,L,6,L,2,R,4,R,4,R,8,R,8,R,8,L,6,L,2` ``` ``` ` Without the memory limit, you could just supply this whole string to function A and have the main routine call A once.` ` However, you'll need to split it into smaller parts.` ``` ``` ` One approach is:` ``` ``` ` • Main routine: A,B,C,B,A,C` ` (ASCII input: 65, 44, 66, 44, 67, 44, 66, 44, 65, 44, 67, 10)` ` • Function A:   R,8,R,8` ` (ASCII input: 82, 44, 56, 44, 82, 44, 56, 10)` ` • Function B:   R,4,R,4,R,8` ` (ASCII input: 82, 44, 52, 44, 82, 44, 52, 44, 82, 44, 56, 10)` ` • Function C:   L,6,L,2` ` (ASCII input: 76, 44, 54, 44, 76, 44, 50, 10)` ``` ``` ` Visually, this would break the desired path into the following parts:` ``` ``` ` A, B, C, B, A, C` ` R,8,R,8, R,4,R,4,R,8, L,6,L,2, R,4,R,4,R,8, R,8,R,8, L,6,L,2` ``` ``` ` CCCCCCA...BBBBB` ` C.....A...B...B` ` C.....A...B...B` ` ......A...B...B` ` ......A...CCC.B` ` ......A.....C.B` ` ^AAAAAAAA...C.B` ` ......A.A...C.B` ` ......AAAAAA#AB` ` ........A...C..` ` ....BBBB#BBBB..` ` ....B...A......` ` ....B...A......` ` ....B...A......` ` ....BBBBA......` ``` ``` ` Of course, the scaffolding outside your ship is much more complex.` ``` ``` ` As the vacuum robot finds other robots and notifies them of the impending solar flare, it also can't help but leave them` ` squeaky clean, collecting any space dust it finds. Once it finishes the programmed set of movements, assuming it hasn't` ` drifted off into space, the cleaning robot will return to its docking station and report the amount of space dust it` ` collected as a large, non-ASCII value in a single output instruction.` ``` ``` ` After visiting every part of the scaffold at least once, how much dust does the vacuum robot report it has collected?` ``` ``` ` Your puzzle answer was 597517.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Solar_flare` ` . https://adventofcode.com/2019/day/9` ` . https://simple.wikipedia.org/wiki/ASCII` ` . https://en.wikipedia.org/wiki/Newline#In_programming_languages` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/17/input`

#### 293 2019/day18/problem 100644 View File

 `@ -0,0 +1,293 @@` `Advent of Code` ``` ``` `--- Day 18: Many-Worlds Interpretation ---` ``` ``` ` As you approach Neptune, a planetary security system detects you and activates a giant tractor beam on Triton! You have no` ` choice but to land.` ``` ``` ` A scan of the local area reveals only one interesting feature: a massive underground vault. You generate a map of the tunnels` ` (your puzzle input). The tunnels are too narrow to move diagonally.` ``` ``` ` Only one entrance (marked @) is present among the open passages (marked .) and stone walls (#), but you also detect an` ` assortment of keys (shown as lowercase letters) and doors (shown as uppercase letters). Keys of a given letter open the door` ` of the same letter: a opens A, b opens B, and so on. You aren't sure which key you need to disable the tractor beam, so` ` you'll need to collect all of them.` ``` ``` ` For example, suppose you have the following map:` ``` ``` ` #########` ` #b.A.@.a#` ` #########` ``` ``` ` Starting from the entrance (@), you can only access a large door (A) and a key (a). Moving toward the door doesn't help you,` ` but you can move 2 steps to collect the key, unlocking A in the process:` ``` ``` ` #########` ` #b.....@#` ` #########` ``` ``` ` Then, you can move 6 steps to collect the only other key, b:` ``` ``` ` #########` ` #@......#` ` #########` ``` ``` ` So, collecting every key took a total of 8 steps.` ``` ``` ` Here is a larger example:` ``` ``` ` ########################` ` #f.D.E.e.C.b.A.@.a.B.c.#` ` ######################.#` ` #d.....................#` ` ########################` ``` ``` ` The only reasonable move is to take key a and unlock door A:` ``` ``` ` ########################` ` #f.D.E.e.C.b.....@.B.c.#` ` ######################.#` ` #d.....................#` ` ########################` ``` ``` ` Then, do the same with key b:` ``` ``` ` ########################` ` #f.D.E.e.C.@.........c.#` ` ######################.#` ` #d.....................#` ` ########################` ``` ``` ` ...and the same with key c:` ``` ``` ` ########################` ` #f.D.E.e.............@.#` ` ######################.#` ` #d.....................#` ` ########################` ``` ``` ` Now, you have a choice between keys d and e. While key e is closer, collecting it now would be slower in the long run than` ` collecting key d first, so that's the best choice:` ``` ``` ` ########################` ` #f...E.e...............#` ` ######################.#` ` #@.....................#` ` ########################` ``` ``` ` Finally, collect key e to unlock door E, then collect key f, taking a grand total of 86 steps.` ``` ``` ` Here are a few more examples:` ``` ``` ` • ########################` ` #...............b.C.D.f#` ` #.######################` ` #.....@.a.B.c.d.A.e.F.g#` ` ########################` ``` ``` ` Shortest path is 132 steps: b, a, c, d, f, e, g` ``` ``` ` • #################` ` #i.G..c...e..H.p#` ` ########.########` ` #j.A..b...f..D.o#` ` ########@########` ` #k.E..a...g..B.n#` ` ########.########` ` #l.F..d...h..C.m#` ` #################` ``` ``` ` Shortest paths are 136 steps;` ` one is: a, f, b, j, g, n, h, d, l, o, e, p, c, i, k, m` ``` ``` ` • ########################` ` #@..............ac.GI.b#` ` ###d#e#f################` ` ###A#B#C################` ` ###g#h#i################` ` ########################` ``` ``` ` Shortest paths are 81 steps; one is: a, c, f, i, d, g, b, e, h` ``` ``` ` How many steps is the shortest path that collects all of the keys?` ``` ``` ` Your puzzle answer was 4270.` ``` ``` `--- Part Two ---` ``` ``` ` You arrive at the vault only to discover that there is not one vault, but four - each with its own entrance.` ``` ``` ` On your map, find the area in the middle that looks like this:` ``` ``` ` ...` ` .@.` ` ...` ``` ``` ` Update your map to instead use the correct data:` ``` ``` ` @#@` ` ###` ` @#@` ``` ``` ` This change will split your map into four separate sections, each with its own entrance:` ``` ``` ` ####### #######` ` #a.#Cd# #a.#Cd#` ` ##...## ##@#@##` ` ##.@.## --> #######` ` ##...## ##@#@##` ` #cB#Ab# #cB#Ab#` ` ####### #######` ``` ``` ` Because some of the keys are for doors in other vaults, it would take much too long to collect all of the keys by yourself.` ` Instead, you deploy four remote-controlled robots. Each starts at one of the entrances (@).` ``` ``` ` Your goal is still to collect all of the keys in the fewest steps, but now, each robot has its own position and can move` ` independently. You can only remotely control a single robot at a time. Collecting a key instantly unlocks any corresponding` ` doors, regardless of the vault in which the key or door is found.` ``` ``` ` For example, in the map above, the top-left robot first collects key a, unlocking door A in the bottom-right vault:` ``` ``` ` #######` ` #@.#Cd#` ` ##.#@##` ` #######` ` ##@#@##` ` #cB#.b#` ` #######` ``` ``` ` Then, the bottom-right robot collects key b, unlocking door B in the bottom-left vault:` ``` ``` ` #######` ` #@.#Cd#` ` ##.#@##` ` #######` ` ##@#.##` ` #c.#.@#` ` #######` ``` ``` ` Then, the bottom-left robot collects key c:` ``` ``` ` #######` ` #@.#.d#` ` ##.#@##` ` #######` ` ##.#.##` ` #@.#.@#` ` #######` ``` ``` ` Finally, the top-right robot collects key d:` ``` ``` ` #######` ` #@.#.@#` ` ##.#.##` ` #######` ` ##.#.##` ` #@.#.@#` ` #######` ``` ``` ` In this example, it only took 8 steps to collect all of the keys.` ``` ``` ` Sometimes, multiple robots might have keys available, or a robot might have to wait for multiple keys to be collected:` ``` ``` ` ###############` ` #d.ABC.#.....a#` ` ######@#@######` ` ###############` ` ######@#@######` ` #b.....#.....c#` ` ###############` ``` ``` ` First, the top-right, bottom-left, and bottom-right robots take turns collecting keys a, b, and c, a total of 6 + 6 + 6 = 18` ` steps. Then, the top-left robot can access key d, spending another 6 steps; collecting all of the keys here takes a minimum` ` of 24 steps.` ``` ``` ` Here's a more complex example:` ``` ``` ` #############` ` #DcBa.#.GhKl#` ` #.###@#@#I###` ` #e#d#####j#k#` ` ###C#@#@###J#` ` #fEbA.#.FgHi#` ` #############` ``` ``` ` • Top-left robot collects key a.` ` • Bottom-left robot collects key b.` ` • Top-left robot collects key c.` ` • Bottom-left robot collects key d.` ` • Top-left robot collects key e.` ` • Bottom-left robot collects key f.` ` • Bottom-right robot collects key g.` ` • Top-right robot collects key h.` ` • Bottom-right robot collects key i.` ` • Top-right robot collects key j.` ` • Bottom-right robot collects key k.` ` • Top-right robot collects key l.` ``` ``` ` In the above example, the fewest steps to collect all of the keys is 32.` ``` ``` ` Here's an example with more choices:` ``` ``` ` #############` ` #g#f.D#..h#l#` ` #F###e#E###.#` ` #dCba@#@BcIJ#` ` #############` ` #nK.L@#@G...#` ` #M###N#H###.#` ` #o#m..#i#jk.#` ` #############` ``` ``` ` One solution with the fewest steps is:` ``` ``` ` • Top-left robot collects key e.` ` • Top-right robot collects key h.` ` • Bottom-right robot collects key i.` ` • Top-left robot collects key a.` ` • Top-left robot collects key b.` ` • Top-right robot collects key c.` ` • Top-left robot collects key d.` ` • Top-left robot collects key f.` ` • Top-left robot collects key g.` ` • Bottom-right robot collects key k.` ` • Bottom-right robot collects key j.` ` • Top-right robot collects key l.` ` • Bottom-left robot collects key n.` ` • Bottom-left robot collects key m.` ` • Bottom-left robot collects key o.` ``` ``` ` This example requires at least 72 steps to collect all keys.` ``` ``` ` After updating your map and using the remote-controlled robots, what is the fewest steps necessary to collect all of the` ` keys?` ``` ``` ` Your puzzle answer was 1982.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Tractor_beam` ` . https://en.wikipedia.org/wiki/Triton_(moon)` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/18/input`

#### 122 2019/day19/problem 100644 View File

 `@ -0,0 +1,122 @@` `Advent of Code` ``` ``` `--- Day 19: Tractor Beam ---` ``` ``` ` Unsure of the state of Santa's ship, you borrowed the tractor beam technology from Triton. Time to test it out.` ``` ``` ` When you're safely away from anything else, you activate the tractor beam, but nothing happens. It's hard to tell whether` ` it's working if there's nothing to use it on. Fortunately, your ship's drone system can be configured to deploy a drone to` ` specific coordinates and then check whether it's being pulled. There's even an Intcode program (your puzzle input) that gives` ` you access to the drone system.` ``` ``` ` The program uses two input instructions to request the X and Y position to which the drone should be deployed. Negative` ` numbers are invalid and will confuse the drone; all numbers should be zero or positive.` ``` ``` ` Then, the program will output whether the drone is stationary (0) or being pulled by something (1). For example, the` ` coordinate X=0, Y=0 is directly in front of the tractor beam emitter, so the drone control program will always report 1 at` ` that location.` ``` ``` ` To better understand the tractor beam, it is important to get a good picture of the beam itself. For example, suppose you` ` scan the 10x10 grid of points closest to the emitter:` ``` ``` ` X` ` 0-> 9` ` 0#.........` ` |.#........` ` v..##......` ` ...###....` ` ....###...` ` Y .....####.` ` ......####` ` ......####` ` .......###` ` 9........##` ``` ``` ` In this example, the number of points affected by the tractor beam in the 10x10 area closest to the emitter is 27.` ``` ``` ` However, you'll need to scan a larger area to understand the shape of the beam. How many points are affected by the tractor` ` beam in the 50x50 area closest to the emitter? (For each of X and Y, this will be 0 through 49.)` ``` ``` ` Your puzzle answer was 217.` ``` ``` `--- Part Two ---` ``` ``` ` You aren't sure how large Santa's ship is. You aren't even sure if you'll need to use this thing on Santa's ship, but it` ` doesn't hurt to be prepared. You figure Santa's ship might fit in a 100x100 square.` ``` ``` ` The beam gets wider as it travels away from the emitter; you'll need to be a minimum distance away to fit a square of that` ` size into the beam fully. (Don't rotate the square; it should be aligned to the same axes as the drone grid.)` ``` ``` ` For example, suppose you have the following tractor beam readings:` ``` ``` ` #.......................................` ` .#......................................` ` ..##....................................` ` ...###..................................` ` ....###.................................` ` .....####...............................` ` ......#####.............................` ` ......######............................` ` .......#######..........................` ` ........########........................` ` .........#########......................` ` ..........#########.....................` ` ...........##########...................` ` ...........############.................` ` ............############................` ` .............#############..............` ` ..............##############............` ` ...............###############..........` ` ................###############.........` ` ................#################.......` ` .................########OOOOOOOOOO.....` ` ..................#######OOOOOOOOOO#....` ` ...................######OOOOOOOOOO###..` ` ....................#####OOOOOOOOOO#####` ` .....................####OOOOOOOOOO#####` ` .....................####OOOOOOOOOO#####` ` ......................###OOOOOOOOOO#####` ` .......................##OOOOOOOOOO#####` ` ........................#OOOOOOOOOO#####` ` .........................OOOOOOOOOO#####` ` ..........................##############` ` ..........................##############` ` ...........................#############` ` ............................############` ` .............................###########` ``` ``` ` In this example, the 10x10 square closest to the emitter that fits entirely within the tractor beam has been marked O. Within` ` it, the point closest to the emitter (the only highlighted O) is at X=25, Y=20.` ``` ``` ` Find the 100x100 square closest to the emitter that fits entirely within the tractor beam; within that square, find the point` ` closest to the emitter. What value do you get if you take that point's X coordinate, multiply it by 10000, then add the` ` point's Y coordinate? (In the example above, this would be 250020.)` ``` ``` ` Your puzzle answer was 6840937.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/day/9` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/19/input`

#### 256 2019/day20/problem 100644 View File

 `@ -0,0 +1,256 @@` `Advent of Code` ``` ``` `--- Day 20: Donut Maze ---` ``` ``` ` You notice a strange pattern on the surface of Pluto and land nearby to get a closer look. Upon closer inspection, you` ` realize you've come across one of the famous space-warping mazes of the long-lost Pluto civilization!` ``` ``` ` Because there isn't much space on Pluto, the civilization that used to live here thrived by inventing a method for folding` ` spacetime. Although the technology is no longer understood, mazes like this one provide a small glimpse into the daily life` ` of an ancient Pluto citizen.` ``` ``` ` This maze is shaped like a donut. Portals along the inner and outer edge of the donut can instantly teleport you from one` ` side to the other. For example:` ``` ``` ` A` ` A` ` #######.#########` ` #######.........#` ` #######.#######.#` ` #######.#######.#` ` #######.#######.#` ` ##### B ###.#` ` BC...## C ###.#` ` ##.## ###.#` ` ##...DE F ###.#` ` ##### G ###.#` ` #########.#####.#` ` DE..#######...###.#` ` #.#########.###.#` ` FG..#########.....#` ` ###########.#####` ` Z` ` Z` ``` ``` ` This map of the maze shows solid walls (#) and open passages (.). Every maze on Pluto has a start (the open tile next to AA)` ` and an end (the open tile next to ZZ). Mazes on Pluto also have portals; this maze has three pairs of portals: BC, DE, and` ` FG. When on an open tile next to one of these labels, a single step can take you to the other tile with the same label. (You` ` can only walk on . tiles; labels and empty space are not traversable.)` ``` ``` ` One path through the maze doesn't require any portals. Starting at AA, you could go down 1, right 8, down 12, left 4, and` ` down 1 to reach ZZ, a total of 26 steps.` ``` ``` ` However, there is a shorter path: You could walk from AA to the inner BC portal (4 steps), warp to the outer BC portal (1` ` step), walk to the inner DE (6 steps), warp to the outer DE (1 step), walk to the outer FG (4 steps), warp to the inner FG (1` ` step), and finally walk to ZZ (6 steps). In total, this is only 23 steps.` ``` ``` ` Here is a larger example:` ``` ``` ` A` ` A` ` #################.#############` ` #.#...#...................#.#.#` ` #.#.#.###.###.###.#########.#.#` ` #.#.#.......#...#.....#.#.#...#` ` #.#########.###.#####.#.#.###.#` ` #.............#.#.....#.......#` ` ###.###########.###.#####.#.#.#` ` #.....# A C #.#.#.#` ` ####### S P #####.#` ` #.#...# #......VT` ` #.#.#.# #.#####` ` #...#.# YN....#.#` ` #.###.# #####.#` ` DI....#.# #.....#` ` #####.# #.###.#` ` ZZ......# QG....#..AS` ` ###.### #######` ` JO..#.#.# #.....#` ` #.#.#.# ###.#.#` ` #...#..DI BU....#..LF` ` #####.# #.#####` ` YN......# VT..#....QG` ` #.###.# #.###.#` ` #.#...# #.....#` ` ###.### J L J #.#.###` ` #.....# O F P #.#...#` ` #.###.#####.#.#####.#####.###.#` ` #...#.#.#...#.....#.....#.#...#` ` #.#####.###.###.#.#.#########.#` ` #...#.#.....#...#.#.#.#.....#.#` ` #.###.#####.###.###.#.#.#######` ` #.#.........#...#.............#` ` #########.###.###.#############` ` B J C` ` U P P` ``` ``` ` Here, AA has no direct path to ZZ, but it does connect to AS and CP. By passing through AS, QG, BU, and JO, you can reach ZZ` ` in 58 steps.` ``` ``` ` In your maze, how many steps does it take to get from the open tile marked AA to the open tile marked ZZ?` ``` ``` ` Your puzzle answer was 552.` ``` ``` `--- Part Two ---` ``` ``` ` Strangely, the exit isn't open when you reach it. Then, you remember: the ancient Plutonians were famous for building` ` recursive spaces.` ``` ``` ` The marked connections in the maze aren't portals: they physically connect to a larger or smaller copy of the maze.` ` Specifically, the labeled tiles around the inside edge actually connect to a smaller copy of the same maze, and the smaller` ` copy's inner labeled tiles connect to yet a smaller copy, and so on.` ``` ``` ` When you enter the maze, you are at the outermost level; when at the outermost level, only the outer labels AA and ZZ` ` function (as the start and end, respectively); all other outer labeled tiles are effectively walls. At any other level, AA` ` and ZZ count as walls, but the other outer labeled tiles bring you one level outward.` ``` ``` ` Your goal is to find a path through the maze that brings you back to ZZ at the outermost level of the maze.` ``` ``` ` In the first example above, the shortest path is now the loop around the right side. If the starting level is 0, then taking` ` the previously-shortest path would pass through BC (to level 1), DE (to level 2), and FG (back to level 1). Because this is` ` not the outermost level, ZZ is a wall, and the only option is to go back around to BC, which would only send you even deeper` ` into the recursive maze.` ``` ``` ` In the second example above, there is no path that brings you to ZZ at the outermost level.` ``` ``` ` Here is a more interesting example:` ``` ``` ` Z L X W C` ` Z P Q B K` ` ###########.#.#.#.#######.###############` ` #...#.......#.#.......#.#.......#.#.#...#` ` ###.#.#.#.#.#.#.#.###.#.#.#######.#.#.###` ` #.#...#.#.#...#.#.#...#...#...#.#.......#` ` #.###.#######.###.###.#.###.###.#.#######` ` #...#.......#.#...#...#.............#...#` ` #.#########.#######.#.#######.#######.###` ` #...#.# F R I Z #.#.#.#` ` #.###.# D E C H #.#.#.#` ` #.#...# #...#.#` ` #.###.# #.###.#` ` #.#....OA WB..#.#..ZH` ` #.###.# #.#.#.#` ` CJ......# #.....#` ` ####### #######` ` #.#....CK #......IC` ` #.###.# #.###.#` ` #.....# #...#.#` ` ###.### #.#.#.#` ` XF....#.# RF..#.#.#` ` #####.# #######` ` #......CJ NM..#...#` ` ###.#.# #.###.#` ` RE....#.# #......RF` ` ###.### X X L #.#.#.#` ` #.....# F Q P #.#.#.#` ` ###.###########.###.#######.#########.###` ` #.....#...#.....#.......#...#.....#.#...#` ` #####.#.###.#######.#######.###.###.#.#.#` ` #.......#.......#.#.#.#.#...#...#...#.#.#` ` #####.###.#####.#.#.#.#.###.###.#.###.###` ` #.......#.....#.#...#...............#...#` ` #############.#.#.###.###################` ` A O F N` ` A A D M` ``` ``` ` One shortest path through the maze is the following:` ``` ``` ` • Walk from AA to XF (16 steps)` ` • Recurse into level 1 through XF (1 step)` ` • Walk from XF to CK (10 steps)` ` • Recurse into level 2 through CK (1 step)` ` • Walk from CK to ZH (14 steps)` ` • Recurse into level 3 through ZH (1 step)` ` • Walk from ZH to WB (10 steps)` ` • Recurse into level 4 through WB (1 step)` ` • Walk from WB to IC (10 steps)` ` • Recurse into level 5 through IC (1 step)` ` • Walk from IC to RF (10 steps)` ` • Recurse into level 6 through RF (1 step)` ` • Walk from RF to NM (8 steps)` ` • Recurse into level 7 through NM (1 step)` ` • Walk from NM to LP (12 steps)` ` • Recurse into level 8 through LP (1 step)` ` • Walk from LP to FD (24 steps)` ` • Recurse into level 9 through FD (1 step)` ` • Walk from FD to XQ (8 steps)` ` • Recurse into level 10 through XQ (1 step)` ` • Walk from XQ to WB (4 steps)` ` • Return to level 9 through WB (1 step)` ` • Walk from WB to ZH (10 steps)` ` • Return to level 8 through ZH (1 step)` ` • Walk from ZH to CK (14 steps)` ` • Return to level 7 through CK (1 step)` ` • Walk from CK to XF (10 steps)` ` • Return to level 6 through XF (1 step)` ` • Walk from XF to OA (14 steps)` ` • Return to level 5 through OA (1 step)` ` • Walk from OA to CJ (8 steps)` ` • Return to level 4 through CJ (1 step)` ` • Walk from CJ to RE (8 steps)` ` • Return to level 3 through RE (1 step)` ` • Walk from RE to IC (4 steps)` ` • Recurse into level 4 through IC (1 step)` ` • Walk from IC to RF (10 steps)` ` • Recurse into level 5 through RF (1 step)` ` • Walk from RF to NM (8 steps)` ` • Recurse into level 6 through NM (1 step)` ` • Walk from NM to LP (12 steps)` ` • Recurse into level 7 through LP (1 step)` ` • Walk from LP to FD (24 steps)` ` • Recurse into level 8 through FD (1 step)` ` • Walk from FD to XQ (8 steps)` ` • Recurse into level 9 through XQ (1 step)` ` • Walk from XQ to WB (4 steps)` ` • Return to level 8 through WB (1 step)` ` • Walk from WB to ZH (10 steps)` ` • Return to level 7 through ZH (1 step)` ` • Walk from ZH to CK (14 steps)` ` • Return to level 6 through CK (1 step)` ` • Walk from CK to XF (10 steps)` ` • Return to level 5 through XF (1 step)` ` • Walk from XF to OA (14 steps)` ` • Return to level 4 through OA (1 step)` ` • Walk from OA to CJ (8 steps)` ` • Return to level 3 through CJ (1 step)` ` • Walk from CJ to RE (8 steps)` ` • Return to level 2 through RE (1 step)` ` • Walk from RE to XQ (14 steps)` ` • Return to level 1 through XQ (1 step)` ` • Walk from XQ to FD (8 steps)` ` • Return to level 0 through FD (1 step)` ` • Walk from FD to ZZ (18 steps)` ``` ``` ` This path takes a total of 396 steps to move from AA at the outermost layer to ZZ at the outermost layer.` ``` ``` ` In your maze, when accounting for recursion, how many steps does it take to get from the open tile marked AA to the open tile` ` marked ZZ, both at the outermost layer?` ``` ``` ` Your puzzle answer was 6492.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Torus` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/20/input`

#### 159 2019/day21/problem 100644 View File

 `@ -0,0 +1,159 @@` `Advent of Code` ``` ``` `--- Day 21: Springdroid Adventure ---` ``` ``` ` You lift off from Pluto and start flying in the direction of Santa.` ``` ``` ` While experimenting further with the tractor beam, you accidentally pull an asteroid directly into your ship! It deals` ` significant damage to your hull and causes your ship to begin tumbling violently.` ``` ``` ` You can send a droid out to investigate, but the tumbling is causing enough artificial gravity that one wrong step could send` ` the droid through a hole in the hull and flying out into space.` ``` ``` ` The clear choice for this mission is a droid that can jump over the holes in the hull - a springdroid.` ``` ``` ` You can use an Intcode program (your puzzle input) running on an ASCII-capable computer to program the springdroid. However,` ` springdroids don't run Intcode; instead, they run a simplified assembly language called springscript.` ``` ``` ` While a springdroid is certainly capable of navigating the artificial gravity and giant holes, it has one downside: it can` ` only remember at most 15 springscript instructions.` ``` ``` ` The springdroid will move forward automatically, constantly thinking about whether to jump. The springscript program defines` ` the logic for this decision.` ``` ``` ` Springscript programs only use Boolean values, not numbers or strings. Two registers are available: T, the temporary value` ` register, and J, the jump register. If the jump register is true at the end of the springscript program, the springdroid will` ` try to jump. Both of these registers start with the value false.` ``` ``` ` Springdroids have a sensor that can detect whether there is ground at various distances in the direction it is facing; these` ` values are provided in read-only registers. Your springdroid can detect ground at four distances: one tile away (A), two` ` tiles away (B), three tiles away (C), and four tiles away (D). If there is ground at the given distance, the register will be` ` true; if there is a hole, the register will be false.` ``` ``` ` There are only three instructions available in springscript:` ``` ``` ` • AND X Y sets Y to true if both X and Y are true; otherwise, it sets Y to false.` ` • OR X Y sets Y to true if at least one of X or Y is true; otherwise, it sets Y to false.` ` • NOT X Y sets Y to true if X is false; otherwise, it sets Y to false.` ``` ``` ` In all three instructions, the second argument (Y) needs to be a writable register (either T or J). The first argument (X)` ` can be any register (including A, B, C, or D).` ``` ``` ` For example, the one-instruction program NOT A J means "if the tile immediately in front of me is not ground, jump".` ``` ``` ` Or, here is a program that jumps if a three-tile-wide hole (with ground on the other side of the hole) is detected:` ``` ``` ` NOT A J` ` NOT B T` ` AND T J` ` NOT C T` ` AND T J` ` AND D J` ``` ``` ` The Intcode program expects ASCII inputs and outputs. It will begin by displaying a prompt; then, input the desired` ` instructions one per line. End each line with a newline (ASCII code 10). When you have finished entering your program,` ` provide the command WALK followed by a newline to instruct the springdroid to begin surveying the hull.` ``` ``` ` If the springdroid falls into space, an ASCII rendering of the last moments of its life will be produced. In these, @ is the` ` springdroid, # is hull, and . is empty space. For example, suppose you program the springdroid like this:` ``` ``` ` NOT D J` ` WALK` ``` ``` ` This one-instruction program sets J to true if and only if there is no ground four tiles away. In other words, it attempts to` ` jump into any hole it finds:` ``` ``` ` .................` ` .................` ` @................` ` #####.###########` ``` ``` ` .................` ` .................` ` .@...............` ` #####.###########` ``` ``` ` .................` ` ..@..............` ` .................` ` #####.###########` ``` ``` ` ...@.............` ` .................` ` .................` ` #####.###########` ``` ``` ` .................` ` ....@............` ` .................` ` #####.###########` ``` ``` ` .................` ` .................` ` .....@...........` ` #####.###########` ``` ``` ` .................` ` .................` ` .................` ` #####@###########` ``` ``` ` However, if the springdroid successfully makes it across, it will use an output instruction to indicate the amount of damage` ` to the hull as a single giant integer outside the normal ASCII range.` ``` ``` ` Program the springdroid with logic that allows it to survey the hull without falling into space. What amount of hull damage` ` does it report?` ``` ``` ` Your puzzle answer was 19354818.` ``` ``` `--- Part Two ---` ``` ``` ` There are many areas the springdroid can't reach. You flip through the manual and discover a way to increase its sensor` ` range.` ``` ``` ` Instead of ending your springcode program with WALK, use RUN. Doing this will enable extended sensor mode, capable of sensing` ` ground up to nine tiles away. This data is available in five new read-only registers:` ``` ``` ` • Register E indicates whether there is ground five tiles away.` ` • Register F indicates whether there is ground six tiles away.` ` • Register G indicates whether there is ground seven tiles away.` ` • Register H indicates whether there is ground eight tiles away.` ` • Register I indicates whether there is ground nine tiles away.` ``` ``` ` All other functions remain the same.` ``` ``` ` Successfully survey the rest of the hull by ending your program with RUN. What amount of hull damage does the springdroid now` ` report?` ``` ``` ` Your puzzle answer was 1143787220.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ``` `References` ``` ``` ` Visible links` ` . https://adventofcode.com/` ` . https://adventofcode.com/2019/about` ` . https://adventofcode.com/2019/events` ` . https://adventofcode.com/2019/settings` ` . https://adventofcode.com/2019/auth/logout` ` . Advent of Code Supporter` ` https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/support` ` . https://adventofcode.com/2019/sponsors` ` . https://adventofcode.com/2019/leaderboard` ` . https://adventofcode.com/2019/stats` ` . https://adventofcode.com/2019/sponsors` ` . https://en.wikipedia.org/wiki/Artificial_gravity` ` . https://adventofcode.com/2019/day/9` ` . https://adventofcode.com/2019/day/17` ` . https://en.wikipedia.org/wiki/Programmable_read-only_memory` ` . https://en.wikipedia.org/wiki/Boolean_data_type` ` . https://adventofcode.com/2019` ` . https://adventofcode.com/2019/day/21/input`

#### 209 2019/day22/problem 100644 View File

 `@ -0,0 +1,209 @@` `Advent of Code` ``` ``` `--- Day 22: Slam Shuffle ---` ``` ``` ` There isn't much to do while you wait for the droids to repair your ship. At least you're drifting in the right direction.` ` You decide to practice a new card shuffle you've been working on.` ``` ``` ` Digging through the ship's storage, you find a deck of space cards! Just like any deck of space cards, there are 10007 cards` ` in the deck numbered 0 through 10006. The deck must be new - they're still in factory order, with 0 on the top, then 1, then` ` 2, and so on, all the way through to 10006 on the bottom.` ``` ``` ` You've been practicing three different techniques that you use while shuffling. Suppose you have a deck of only 10 cards` ` (numbered 0 through 9):` ``` ``` ` To deal into new stack, create a new stack of cards by dealing the top card of the deck onto the top of the new stack` ` repeatedly until you run out of cards:` ``` ``` ` Top Bottom` ` 0 1 2 3 4 5 6 7 8 9 Your deck` ` New stack` ``` ``` ` 1 2 3 4 5 6 7 8 9 Your deck` ` 0 New stack` ``` ``` ` 2 3 4 5 6 7 8 9 Your deck` ` 1 0 New stack` ``` ``` ` 3 4 5 6 7 8 9 Your deck` ` 2 1 0 New stack` ``` ``` ` Several steps later...` ``` ``` ` 9 Your deck` ` 8 7 6 5 4 3 2 1 0 New stack` ``` ``` ` Your deck` ` 9 8 7 6 5 4 3 2 1 0 New stack` ``` ``` ` Finally, pick up the new stack you've just created and use it as the deck for the next technique.` ``` ``` ` To cut N cards, take the top N cards off the top of the deck and move them as a single unit to the bottom of the deck,` ` retaining their order. For example, to cut 3:` ``` ``` ` Top Bottom` ` 0 1 2 3 4 5 6 7 8 9 Your deck` ``` ``` ` 3 4 5 6 7 8 9 Your deck` ` 0 1 2 Cut cards` ``` ``` ` 3 4 5 6 7 8 9 Your deck` ` 0 1 2 Cut cards` ``` ``` ` 3 4 5 6 7 8 9 0 1 2 Your deck` ``` ``` ` You've also been getting pretty good at a version of this technique where N is negative! In that case, cut (the absolute` ` value of) N cards from the bottom of the deck onto the top. For example, to cut -4:` ``` ``` ` Top Bottom` ` 0 1 2 3 4 5 6 7 8 9 Your deck` ``` ``` ` 0 1 2 3 4 5 Your deck` ` 6 7 8 9 Cut cards` ``` ``` ` 0 1 2 3 4 5 Your deck` ` 6 7 8 9 Cut cards` ``` ``` ` 6 7 8 9 0 1 2 3 4 5 Your deck` ``` ``` ` To deal with increment N, start by clearing enough space on your table to lay out all of the cards individually in a long` ` line. Deal the top card into the leftmost position. Then, move N positions to the right and deal the next card there. If you` ` would move into a position past the end of the space on your table, wrap around and keep counting from the leftmost card` ` again. Continue this process until you run out of cards.` ``` ``` ` For example, to deal with increment 3:` ``` ``` ` 0 1 2 3 4 5 6 7 8 9 Your deck` ` . . . . . . . . . . Space on table` ` ^ Current position` ``` ``` ` Deal the top card to the current position:` ``` ``` ` 1 2 3 4 5 6 7 8 9 Your deck` ` 0 . . . . . . . . . Space on table` ` ^ Current position` ``` ``` ` Move the current position right 3:` ``` ``` ` 1 2 3 4 5 6 7 8 9 Your deck` ` 0 . . . . . . . . . Space on table` ` ^ Current position` ``` ``` ` Deal the top card:` ``` ``` ` 2 3 4 5 6 7 8 9 Your deck` ` 0 . . 1 . . . . . . Space on table` ` ^ Current position` ``` ``` ` Move right 3 and deal:` ``` ``` ` 3 4 5 6 7 8 9 Your deck` ` 0 . . 1 . . 2 . . . Space on table` ` ^ Current position` ``` ``` ` Move right 3 and deal:` ``` ``` ` 4 5 6 7 8 9 Your deck` ` 0 . . 1 . . 2 . . 3 Space on table` ` ^ Current position` ``` ``` ` Move right 3, wrapping around, and deal:` ``` ``` ` 5 6 7 8 9 Your deck` ` 0 . 4 1 . . 2 . . 3 Space on table` ` ^ Current position` ``` ``` ` And so on:` ``` ``` ` 0 7 4 1 8 5 2 9 6 3 Space on table` ``` ``` ` Positions on the table which already contain cards are still counted; they're not skipped. Of course, this technique is` ` carefully designed so it will never put two cards in the same position or leave a position empty.` ``` ``` ` Finally, collect the cards on the table so that the leftmost card ends up at the top of your deck, the card to its right ends` ` up just below the top card, and so on, until the rightmost card ends up at the bottom of the deck.` ``` ``` ` The complete shuffle process (your puzzle input) consists of applying many of these techniques. Here are some examples that` ` combine techniques; they all start with a factory order deck of 10 cards:` ``` ``` ` deal with increment 7` ` deal into new stack` ` deal into new stack` ` Result: 0 3 6 9 2 5 8 1 4 7` ``` ``` ` cut 6` ` deal with increment 7` ` deal into new stack` ` Result: 3 0 7 4 1 8 5 2 9 6` ``` ``` ` deal with increment 7` ` deal with increment 9` ` cut -2` ` Result: 6 3 0 7 4 1 8 5 2 9` ``` ``` ` deal into new stack` ` cut -2` ` deal with increment 7` ` cut 8` ` cut -4` ` deal with increment 7` ` cut 3` ` deal with increment 9` ` deal with increment 3` ` cut -1` ` Result: 9 2 5 8 1 4 7 0 3 6` ``` ``` ` Positions within the deck count from 0 at the top, then 1 for the card immediately below the top card, and so on to the` ` bottom. (That is, cards start in the position matching their number.)` ``` ``` ` After shuffling your factory order deck of 10007 cards, what is the position of card 2019?` ``` ``` ` Your puzzle answer was 6129.` ``` ``` `--- Part Two ---` ``` ``` ` After a while, you realize your shuffling skill won't improve much more with merely a single deck of cards. You ask every 3D` ` printer on the ship to make you some more cards while you check on the ship repairs. While reviewing the work the droids have` ` finished so far, you think you see Halley's Comet fly past!` ``` ``` ` When you get back, you discover that the 3D printers have combined their power to create for you a single, giant, brand new,` ` factory order deck of 119315717514047 space cards.` ``` ``` ` Finally, a deck of cards worthy of shuffling!` ``` ``` ` You decide to apply your complete shuffle process (your puzzle input) to the deck 101741582076661 times in a row.` ``` ``` ` You'll need to be careful, though - one wrong move with this many cards and you might overflow your entire ship!` ``` ``` ` After shuffling your new, giant, factory order deck that many times, what number is on the card that ends up in position` ` 2020?` ``` ``` ` Your puzzle answer was 71345377301237.` ``` ``` ` Both parts of this puzzle are complete! They provide two gold stars: **` ``` ``` ` At this point, all that is left is for you to admire your Advent calendar.` ``` ``` ` If you still want to see it, you can get your puzzle input.` ``` ```