Mercurial > repos > other > adventofcode2023
changeset 19:1e16a25a9553
Strip down the text to just the puzzle, not the fluff
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 11 Dec 2023 20:38:55 +0000 |
parents | ddb69833346c |
children | fac484765bc9 |
files | day1.txt day10.txt day11.txt day2.txt day3.txt day4.txt day5.txt day6.txt day7.txt day8.txt day9.txt |
diffstat | 11 files changed, 83 insertions(+), 138 deletions(-) [+] |
line wrap: on
line diff
--- a/day1.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day1.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,15 +1,5 @@ --- Day 1: Trebuchet?! --- -Something is wrong with global snow production, and you've been selected to take a look. The Elves have even given you a map; on it, they've used stars to mark the top fifty locations that are likely to be having problems. - -You've been doing this long enough to know that to restore snow operations, you need to check all fifty stars by December 25th. - -Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star. Good luck! - -You try to ask why they can't just use a weather machine ("not powerful enough") and where they're even sending you ("the sky") and why your map looks mostly blank ("you sure ask a lot of questions") and hang on did you just say the sky ("of course, where do you think snow comes from") when you realize that the Elves are already loading you into a trebuchet ("please hold still, we need to strap you in"). - -As they're making the final adjustments, they discover that their calibration document (your puzzle input) has been amended by a very young Elf who was apparently just excited to show off her art skills. Consequently, the Elves are having trouble reading the values on the document. - The newly-improved calibration document consists of lines of text; each line originally contained a specific calibration value that the Elves now need to recover. On each line, the calibration value can be found by combining the first digit and the last digit (in that order) to form a single two-digit number. For example:
--- a/day10.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day10.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,12 +1,6 @@ --- Day 10: Pipe Maze --- -You use the hang glider to ride the hot air from Desert Island all the way up to the floating metal island. This island is surprisingly cold and there definitely aren't any thermals to glide on, so you leave your hang glider behind. - -You wander around for a while, but you don't find any people or animals. However, you do occasionally find signposts labeled "Hot Springs" pointing in a seemingly consistent direction; maybe you can find someone at the hot springs and ask them where the desert-machine parts are made. - -The landscape here is alien; even the flowers and trees are made of metal. As you stop to admire some metal grass, you notice something metallic scurry away in your peripheral vision and jump into a big pipe! It didn't look like any animal you've ever seen; if you want a better look, you'll need to get ahead of it. - -Scanning the area, you discover that the entire field you're standing on is densely packed with pipes; it was hard to tell at first because they're the same metallic silver color as the "ground". You make a quick sketch of all of the surface pipes you can see (your puzzle input). +You are in an area filled with pipes/paths. Your puzzle input is a map of the path of those pipes. The pipes are arranged in a two-dimensional grid of tiles: @@ -17,9 +11,9 @@ 7 is a 90-degree bend connecting south and west. F is a 90-degree bend connecting south and east. . is ground; there is no pipe in this tile. - S is the starting position of the animal; there is a pipe on this tile, but your sketch doesn't show what shape the pipe has. + S is the starting position; there is a pipe on this tile, but your sketch doesn't show what shape the pipe has. -Based on the acoustics of the animal's scurrying, you're confident the pipe that contains the animal is one large, continuous loop. +There is at least one continuous loop. You want to get to the point that is furthest around the path from the start point. For example, here is a square loop of pipe: @@ -29,7 +23,7 @@ .L-J. ..... -If the animal had entered this loop in the northwest corner, the sketch would instead look like this: +If the start is in the northwest corner, the sketch would instead look like this: ..... .S-7. @@ -65,9 +59,7 @@ |F--J LJ.LJ -If you want to get out ahead of the animal, you should find the tile in the loop that is farthest from the starting position. Because the animal is in the pipe, it doesn't make sense to measure this by direct distance. Instead, you need to find the tile that would take the longest number of steps along the loop to reach from the starting point - regardless of which way around the loop the animal went. - -In the first example with the square loop: +When measuring the distance in the first example with the square loop: ..... .S-7. @@ -105,9 +97,7 @@ --- Part Two --- -You quickly reach the farthest point of the loop, but the animal never emerges. Maybe its nest is within the area enclosed by the loop? - -To determine whether it's even worth taking the time to search for such a nest, you should calculate how many tiles are contained within the loop. For example: +Maybe there is something enclosed within the loops of the path? You need to calculate how many tiles are contained within the loop. For example: ........... .S-------7. @@ -201,4 +191,4 @@ In this last example, 10 tiles are enclosed by the loop. -Figure out whether you have time to search for the nest by calculating the area within the loop. How many tiles are enclosed by the loop? +How many tiles are enclosed by the loop?
--- a/day11.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day11.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,12 +1,6 @@ --- Day 11: Cosmic Expansion --- -You continue following signs for "Hot Springs" and eventually come across an observatory. The Elf within turns out to be a researcher studying cosmic expansion using the giant telescope here. - -He doesn't know anything about the missing machine parts; he's only visiting for this research project. However, he confirms that the hot springs are the next-closest area likely to have people; he'll even take you straight there once he's done with today's observation analysis. - -Maybe you can help him with the analysis to speed things up? - -The researcher has collected a bunch of data and compiled the data into a single giant image (your puzzle input). The image includes empty space (.) and galaxies (#). For example: +There is a map (your puzzle input). The image includes empty space (.) and galaxies (#). For example: ...#...... .......#.. @@ -19,9 +13,7 @@ .......#.. #...#..... -The researcher is trying to figure out the sum of the lengths of the shortest path between every pair of galaxies. However, there's a catch: the universe expanded in the time it took the light from those galaxies to reach the observatory. - -Due to something involving gravitational effects, only some space expands. In fact, the result is that any rows or columns that contain no galaxies should all actually be twice as big. +We need to calculate the distance between each galaxy. But the space between them is non-linear. Any rows or columns that contain no galaxies should all actually be twice as big. In the above example, three columns and two rows contain no galaxies: @@ -97,8 +89,6 @@ --- Part Two --- -The galaxies are much older (and thus much farther apart) than the researcher initially estimated. - Now, instead of the expansion you did before, make each empty row or column one million times larger. That is, each empty row should be replaced with 1000000 empty rows, and each empty column should be replaced with 1000000 empty columns. (In the example above, if each empty row or column were merely 10 times larger, the sum of the shortest paths between every pair of galaxies would be 1030. If each empty row or column were merely 100 times larger, the sum of the shortest paths between every pair of galaxies would be 8410. However, your universe will need to expand far beyond these values.)
--- a/day2.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day2.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,12 +1,8 @@ --- Day 2: Cube Conundrum --- -You're launched high into the atmosphere! The apex of your trajectory just barely reaches the surface of a large island floating in the sky. You gently land in a fluffy pile of leaves. It's quite cold, but you don't see much snow. An Elf runs over to greet you. - -The Elf explains that you've arrived at Snow Island and apologizes for the lack of snow. He'll be happy to explain the situation, but it's a bit of a walk, so you have some time. They don't get many visitors up here; would you like to play a game in the meantime? +There is a small bag and some cubes which are either red, green, or blue. Each time you play this game, a secret number of cubes of each color are hidden in the bag, and your goal is to figure out information about the number of cubes. -As you walk, the Elf shows you a small bag and some cubes which are either red, green, or blue. Each time you play this game, he will hide a secret number of cubes of each color in the bag, and your goal is to figure out information about the number of cubes. - -To get information, once a bag has been loaded with cubes, the Elf will reach into the bag, grab a handful of random cubes, show them to you, and then put them back in the bag. He'll do this a few times per game. +To get information, a handful of random cubes will be taken, shown to you, and then put back in the bag. This will be repeated You play several games and record the information from each game (your puzzle input). Each game is listed with its ID number (like the 11 in Game 11: ...) followed by a semicolon-separated list of subsets of cubes that were revealed from the bag (like 3 red, 5 green, 4 blue). @@ -20,8 +16,30 @@ In game 1, three sets of cubes are revealed from the bag (and then put back again). The first set is 3 blue cubes and 4 red cubes; the second set is 1 red cube, 2 green cubes, and 6 blue cubes; the third set is only 2 green cubes. -The Elf would first like to know which games would have been possible if the bag contained only 12 red cubes, 13 green cubes, and 14 blue cubes? +Which games would have been possible if the bag contained only 12 red cubes, 13 green cubes, and 14 blue cubes? -In the example above, games 1, 2, and 5 would have been possible if the bag had been loaded with that configuration. However, game 3 would have been impossible because at one point the Elf showed you 20 red cubes at once; similarly, game 4 would also have been impossible because the Elf showed you 15 blue cubes at once. If you add up the IDs of the games that would have been possible, you get 8. +In the example above, games 1, 2, and 5 would have been possible if the bag had been loaded with that configuration. However, game 3 would have been impossible because at one point you saw 20 red cubes at once; similarly, game 4 would also have been impossible because you saw 15 blue cubes at once. If you add up the IDs of the games that would have been possible, you get 8. Determine which games would have been possible if the bag had been loaded with only 12 red cubes, 13 green cubes, and 14 blue cubes. What is the sum of the IDs of those games? + +--- Part Two --- + +In each game you played, what is the fewest number of cubes of each color that could have been in the bag to make the game possible? + +Again consider the example games from earlier: + +Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green +Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue +Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red +Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red +Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green + + In game 1, the game could have been played with as few as 4 red, 2 green, and 6 blue cubes. If any color had even one fewer cube, the game would have been impossible. + Game 2 could have been played with a minimum of 1 red, 3 green, and 4 blue cubes. + Game 3 must have been played with at least 20 red, 13 green, and 6 blue cubes. + Game 4 required at least 14 red, 3 green, and 15 blue cubes. + Game 5 needed no fewer than 6 red, 3 green, and 2 blue cubes in the bag. + +The power of a set of cubes is equal to the numbers of red, green, and blue cubes multiplied together. The power of the minimum set of cubes in game 1 is 48. In games 2-5 it was 12, 1560, 630, and 36, respectively. Adding up these five powers produces the sum 2286. + +For each game, find the minimum set of cubes that must have been present. What is the sum of the power of these sets? \ No newline at end of file
--- a/day3.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day3.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,16 +1,10 @@ -You and the Elf eventually reach a gondola lift station; he says the gondola lift will take you up to the water source, but this is as far as he can bring you. You go inside. +--- Day 3: Gear Ratios --- -It doesn't take long to find the gondolas, but there seems to be a problem: they're not moving. - -"Aaah!" +A part is missing from a system. If you can add up all the part numbers in the schematic, it should be easy to work out which part is missing. -You turn around to see a slightly-greasy Elf with a wrench and a look of surprise. "Sorry, I wasn't expecting anyone! The gondola lift isn't working right now; it'll still be a while before I can fix it." You offer to help. - -The engineer explains that an engine part seems to be missing from the engine, but nobody can figure out which one. If you can add up all the part numbers in the engine schematic, it should be easy to work out which part is missing. +The schematic (your puzzle input) consists of a visual representation of the system. There are lots of numbers and symbols you don't really understand, but apparently any number adjacent to a symbol, even diagonally, is a "part number" and should be included in your sum. (Periods (.) do not count as a symbol.) -The engine schematic (your puzzle input) consists of a visual representation of the engine. There are lots of numbers and symbols you don't really understand, but apparently any number adjacent to a symbol, even diagonally, is a "part number" and should be included in your sum. (Periods (.) do not count as a symbol.) - -Here is an example engine schematic: +Here is an example schematic: 467..114.. ...*...... @@ -25,4 +19,27 @@ In this schematic, two numbers are not part numbers because they are not adjacent to a symbol: 114 (top right) and 58 (middle right). Every other number is adjacent to a symbol and so is a part number; their sum is 4361. -Of course, the actual engine schematic is much larger. What is the sum of all of the part numbers in the engine schematic? \ No newline at end of file +Of course, the actual schematic is much larger. What is the sum of all of the part numbers in the schematic? + +--- Part Two --- + +The missing part wasn't the only issue - one of the gears in the schematic is wrong. A gear is any * symbol that is adjacent to exactly two part numbers. Its gear ratio is the result of multiplying those two numbers together. + +This time, you need to find the gear ratio of every gear and add them all up to figure out which gear needs to be replaced. + +Consider the same schematic again: + +467..114.. +...*...... +..35..633. +......#... +617*...... +.....+.58. +..592..... +......755. +...$.*.... +.664.598.. + +In this schematic, there are two gears. The first is in the top left; it has part numbers 467 and 35, so its gear ratio is 16345. The second gear is in the lower right; its gear ratio is 451490. (The * adjacent to 617 is not a gear because it is only adjacent to one part number.) Adding up all of the gear ratios produces 467835. + +What is the sum of all of the gear ratios in your schematic? \ No newline at end of file
--- a/day4.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day4.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,18 +1,8 @@ --- Day 4: Scratchcards --- -The gondola takes you up. Strangely, though, the ground doesn't seem to be coming with you; you're not climbing a mountain. As the circle of Snow Island recedes below you, an entire new landmass suddenly appears above you! The gondola carries you to the surface of the new island and lurches into the station. - -As you exit the gondola, the first thing you notice is that the air here is much warmer than it was on Snow Island. It's also quite humid. Is this where the water source is? - -The next thing you notice is an Elf sitting on the floor across the station in what seems to be a pile of colorful square cards. +Each scratchcard has two lists of numbers separated by a vertical bar (|): a list of winning numbers and then a list of numbers you have. You organize the information into a table (your puzzle input). -"Oh! Hello!" The Elf excitedly runs over to you. "How may I be of service?" You ask about water sources. - -"I'm not sure; I just operate the gondola lift. That does sound like something we'd have, though - this is Island Island, after all! I bet the gardener would know. He's on a different island, though - er, the small kind surrounded by water, not the floating kind. We really need to come up with a better naming scheme. Tell you what: if you can help me with something quick, I'll let you borrow my boat and you can go visit the gardener. I got all these scratchcards as a gift, but I can't figure out what I've won." - -The Elf leads you over to the pile of colorful cards. There, you discover dozens of scratchcards, all with their opaque covering already scratched off. Picking one up, it looks like each card has two lists of numbers separated by a vertical bar (|): a list of winning numbers and then a list of numbers you have. You organize the information into a table (your puzzle input). - -As far as the Elf has been able to figure out, you have to figure out which of the numbers you have appear in the list of winning numbers. The first match makes the card worth one point and each match after the first doubles the point value of that card. +You have to figure out which of the numbers you have appear in the list of winning numbers. The first match makes the card worth one point and each match after the first doubles the point value of that card. For example: @@ -31,15 +21,13 @@ Card 5 has no winning numbers, so it is worth no points. Card 6 has no winning numbers, so it is worth no points. -So, in this example, the Elf's pile of scratchcards is worth 13 points. +So, in this example, the scratchcards are worth 13 points. -Take a seat in the large pile of colorful cards. How many points are they worth in total? +How many points is the puzzle input worth in total? --- Part Two --- -Just as you're about to report your findings to the Elf, one of you realizes that the rules have actually been printed on the back of every card this whole time. - -There's no such thing as "points". Instead, scratchcards only cause you to win more scratchcards equal to the number of winning numbers you have. +Actually, there's no such thing as "points". Instead, scratchcards only cause you to win more scratchcards equal to the number of winning numbers you have. Specifically, you win copies of the scratchcards below the winning card equal to the number of matches. So, if card 10 were to have 5 matching numbers, you would win one copy each of cards 11, 12, 13, 14, and 15.
--- a/day5.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day5.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,15 +1,5 @@ --- Day 5: If You Give A Seed A Fertilizer --- -You take the boat and find the gardener right where you were told he would be: managing a giant "garden" that looks more to you like a farm. - -"A water source? Island Island is the water source!" You point out that Snow Island isn't receiving any water. - -"Oh, we had to stop the water because we ran out of sand to filter it with! Can't make snow with dirty water. Don't worry, I'm sure we'll get more sand soon; we only turned off the water a few days... weeks... oh no." His face sinks into a look of horrified realization. - -"I've been so busy making sure everyone here has food that I completely forgot to check why we stopped getting more sand! There's a ferry leaving soon that is headed over in that direction - it's much faster than your boat. Could you please go check it out?" - -You barely have time to agree to this request when he brings up another. "While you wait for the ferry, maybe you can help us with our food production problem. The latest Island Island Almanac just arrived and we're having trouble making sense of it." - The almanac (your puzzle input) lists all of the seeds that need to be planted. It also lists what type of soil to use with each kind of seed, what type of fertilizer to use with each kind of soil, what type of water to use with each kind of fertilizer, and so on. Every type of seed, soil, fertilizer and so on is identified with a number, but numbers are reused by each category - that is, soil 123 and fertilizer 123 aren't necessarily related to each other. For example: @@ -88,7 +78,7 @@ Seed number 55 corresponds to soil number 57. Seed number 13 corresponds to soil number 13. -The gardener and his team want to get started as soon as possible, so they'd like to know the closest location that needs a seed. Using these maps, find the lowest location number that corresponds to any of the initial seeds. To do this, you'll need to convert each seed number through other categories until you can find its corresponding location number. In this example, the corresponding types are: +We need to know the closest location that needs a seed. Using these maps, find the lowest location number that corresponds to any of the initial seeds. To do this, you'll need to convert each seed number through other categories until you can find its corresponding location number. In this example, the corresponding types are: Seed 79, soil 81, fertilizer 81, water 81, light 74, temperature 78, humidity 78, location 82. Seed 14, soil 14, fertilizer 53, water 49, light 42, temperature 42, humidity 43, location 43. @@ -102,9 +92,7 @@ --- Part Two --- -Everyone will starve if you only plant such a small number of seeds. Re-reading the almanac, it looks like the seeds: line actually describes ranges of seed numbers. - -The values on the initial seeds: line come in pairs. Within each pair, the first value is the start of the range and the second value is the length of the range. So, in the first line of the example above: +Actually, the values on the initial seeds: line come in pairs. Within each pair, the first value is the start of the range and the second value is the length of the range. So, in the first line of the example above: seeds: 79 14 55 13
--- a/day6.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day6.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,14 +1,6 @@ --- Day 6: Wait For It --- -The ferry quickly brings you across Island Island. After asking around, you discover that there is indeed normally a large pile of sand somewhere near here, but you don't see anything besides lots of water and the small island where the ferry has docked. - -As you try to figure out what to do next, you notice a poster on a wall near the ferry dock. "Boat races! Open to the public! Grand prize is an all-expenses-paid trip to Desert Island!" That must be where the sand comes from! Best of all, the boat races are starting in just a few minutes. - -You manage to sign up as a competitor in the boat races just in time. The organizer explains that it's not really a traditional race - instead, you will get a fixed amount of time during which your boat has to travel as far as it can, and you win if your boat goes the farthest. - -As part of signing up, you get a sheet of paper (your puzzle input) that lists the time allowed for each race and also the best distance ever recorded in that race. To guarantee you win the grand prize, you need to make sure you go farther in each race than the current record holder. - -The organizer brings you over to the area where the boat races are held. The boats are much smaller than you expected - they're actually toy boats, each with a big button on top. Holding down the button charges the boat, and releasing the button allows the boat to move. Boats move faster if their button was held longer, but time spent holding the button counts against the total race time. You can only hold the button at the start of the race, and boats don't move until the button is released. +There is a race for toy boats with a button on top. Holding down the button charges the boat, and releasing the button allows the boat to move. Boats move faster if their button was held longer, but time spent holding the button counts against the total race time. You can only hold the button at the start of the race, and boats don't move until the button is released. You want to beat the record distance for a given race duration. For example: @@ -46,7 +38,7 @@ --- Part Two --- -As the race is about to start, you realize the piece of paper with race times and record distances you got earlier actually just has very bad kerning. There's really only one race - ignore the spaces between the numbers on each line. +The race times and record distances you got earlier are really only one race - ignore the spaces between the numbers on each line. So, the example from before:
--- a/day7.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day7.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,21 +1,5 @@ --- Day 7: Camel Cards --- -Your all-expenses-paid trip turns out to be a one-way, five-minute ride in an airship. (At least it's a cool airship!) It drops you off at the edge of a vast desert and descends back to Island Island. - -"Did you bring the parts?" - -You turn around to see an Elf completely covered in white clothing, wearing goggles, and riding a large camel. - -"Did you bring the parts?" she asks again, louder this time. You aren't sure what parts she's looking for; you're here to figure out why the sand stopped. - -"The parts! For the sand, yes! Come with me; I will show you." She beckons you onto the camel. - -After riding a bit across the sands of Desert Island, you can see what look like very large rocks covering half of the horizon. The Elf explains that the rocks are all along the part of Desert Island that is directly above Island Island, making it hard to even get there. Normally, they use big machines to move the rocks and filter the sand, but the machines have broken down because Desert Island recently stopped receiving the parts they need to fix the machines. - -You've already assumed it'll be your job to figure out why the parts stopped when she asks if you can help. You agree automatically. - -Because the journey will take a few days, she offers to teach you the game of Camel Cards. Camel Cards is sort of similar to poker except it's designed to be easier to play while riding a camel. - In Camel Cards, you get a list of hands, and your goal is to order them based on the strength of each hand. A hand consists of five cards labeled one of A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, or 2. The relative strength of each card follows this order, where A is the highest and 2 is the lowest. Every hand is exactly one type. From strongest to weakest, they are: @@ -57,7 +41,7 @@ --- Part Two --- -To make things a little more interesting, the Elf introduces one additional rule. Now, J cards are jokers - wildcards that can act like whatever card would make the hand the strongest type possible. +Now, J cards are jokers - wildcards that can act like whatever card would make the hand the strongest type possible. To balance this, J cards are now the weakest individual cards, weaker even than 2. The other cards stay in the same order: A, K, Q, T, 9, 8, 7, 6, 5, 4, 3, 2, J.
--- a/day8.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day8.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,12 +1,8 @@ --- Day 8: Haunted Wasteland --- -You're still riding a camel across Desert Island when you spot a sandstorm quickly approaching. When you turn to warn the Elf, she disappears before your eyes! To be fair, she had just finished warning you about ghosts a few minutes ago. - -One of the camel's pouches is labeled "maps" - sure enough, it's full of documents (your puzzle input) about how to navigate the desert. At least, you're pretty sure that's what they are; one of the documents contains a list of left/right instructions, and the rest of the documents seem to describe some kind of network of labeled nodes. +You have a map that describes a list of nodes. It seems like you're meant to use the left/right instructions to navigate the network. -It seems like you're meant to use the left/right instructions to navigate the network. Perhaps if you have the camel follow the same instructions, you can escape the haunted wasteland! - -After examining the maps for a bit, two nodes stick out: AAA and ZZZ. You feel like AAA is where you are now, and you have to follow the left/right instructions until you reach ZZZ. +AAA is where you are now, and you have to follow the left/right instructions until you reach ZZZ. This format defines each node of the network individually. For example: @@ -34,11 +30,7 @@ --- Part Two --- -The sandstorm is upon you and you aren't any closer to escaping the wasteland. You had the camel follow the instructions, but you've barely left your starting position. It's going to take significantly more steps to escape! - -What if the map isn't for people - what if the map is for ghosts? Are ghosts even bound by the laws of spacetime? Only one way to find out. - -After examining the maps a bit longer, your attention is drawn to a curious fact: the number of nodes with names ending in A is equal to the number ending in Z! If you were a ghost, you'd probably just start at every node that ends with A and follow all of the paths at the same time until they all simultaneously end up at nodes that end with Z. +The number of nodes with names ending in A is equal to the number ending in Z! You actually have to start at every node that ends with A and follow all of the paths at the same time until they all simultaneously end up at nodes that end with Z. For example:
--- a/day9.txt Mon Dec 11 20:08:47 2023 +0000 +++ b/day9.txt Mon Dec 11 20:38:55 2023 +0000 @@ -1,20 +1,12 @@ --- Day 9: Mirage Maintenance --- -You ride the camel through the sandstorm and stop where the ghost's maps told you to stop. The sandstorm subsequently subsides, somehow seeing you standing at an oasis! - -The camel goes to get some water and you stretch your neck. As you look up, you discover what must be yet another giant floating island, this one made of metal! That must be where the parts to fix the sand machines come from. - -There's even a hang glider partially buried in the sand here; once the sun rises and heats up the sand, you might be able to use the glider and the hot air to get all the way up to the metal island! - -While you wait for the sun to rise, you admire the oasis hidden here in the middle of Desert Island. It must have a delicate ecosystem; you might as well take some ecological readings while you wait. Maybe you can report any environmental instabilities you find to someone so the oasis can be around for the next sandstorm-worn traveler. - -You pull out your handy Oasis And Sand Instability Sensor and analyze your surroundings. The OASIS produces a report of many values and how they are changing over time (your puzzle input). Each line in the report contains the history of a single value. For example: +You have a report of many values and how they are changing over time (your puzzle input). Each line in the report contains the history of a single value. For example: 0 3 6 9 12 15 1 3 6 10 15 21 10 13 16 21 30 45 -To best protect the oasis, your environmental report should include a prediction of the next value in each history. To do this, start by making a new sequence from the difference at each step of your history. If that sequence is not all zeroes, repeat this process, using the sequence you just generated as the input sequence. Once all of the values in your latest sequence are zeroes, you can extrapolate what the next value of the original history should be. +You need to report a prediction of the next value in each history. To do this, start by making a new sequence from the difference at each step of your history. If that sequence is not all zeroes, repeat this process, using the sequence you just generated as the input sequence. Once all of the values in your latest sequence are zeroes, you can extrapolate what the next value of the original history should be. In the above dataset, the first history is 0 3 6 9 12 15. Because the values increase by 3 each step, the first sequence of differences that you generate will be 3 3 3 3 3. Note that this sequence has one fewer value than the input sequence because at each step it considers two numbers from the input. Since these values aren't all zero, repeat the process: the values differ by 0 at each step, so the next sequence is 0 0 0 0. This means you have enough information to extrapolate the history! Visually, these sequences can be arranged like this: @@ -70,4 +62,8 @@ If you find the next value for each history in this example and add them together, you get 114. -Analyze your OASIS report and extrapolate the next value for each history. What is the sum of these extrapolated values? +What is the sum of these extrapolated values? + +--- Part 2 --- + +Now extrapolate backwards in the same manner and sum _those_ values.