diff --git a/2015/day01/problem b/2015/day01/problem index 2b1d5b5..bc36bc8 100644 --- a/2015/day01/problem +++ b/2015/day01/problem @@ -1,34 +1,27 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 1: Not Quite Lisp --- - Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by - stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December - 25th. + Santa was hoping for a white Christmas, but his weather machine's "snow" + function is powered by stars, and he's fresh out! To save Christmas, he + needs you to collect fifty stars by December 25th. - Collect stars by helping Santa solve puzzles. Two puzzles will be made available on each day in - the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle - grants one star. Good luck! + Collect stars by helping Santa solve 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! Here's an easy puzzle to warm you up. - Santa is trying to deliver presents in a large apartment building, but he can't find the right - floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) - and then follows the instructions one character at a time. + Santa is trying to deliver presents in a large apartment building, but he + can't find the right floor - the directions he got are a little confusing. + He starts on the ground floor (floor 0) and then follows the instructions + one character at a time. - An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means - he should go down one floor. + An opening parenthesis, (, means he should go up one floor, and a closing + parenthesis, ), means he should go down one floor. - The apartment building is very tall, and the basement is very deep; he will never find the top - or bottom floors. + The apartment building is very tall, and the basement is very deep; he will + never find the top or bottom floors. For example: @@ -44,16 +37,17 @@ --- Part Two --- - Now, given the same instructions, find the position of the first character that causes him to - enter the basement (floor -1). The first character in the instructions has position 1, the - second character has position 2, and so on. + Now, given the same instructions, find the position of the first character + that causes him to enter the basement (floor -1). The first character in the + instructions has position 1, the second character has position 2, and so on. For example: • ) causes him to enter the basement at character position 1. • ()()) causes him to enter the basement at character position 5. - What is the position of the character that causes Santa to first enter the basement? + What is the position of the character that causes Santa to first enter the + basement? Your puzzle answer was 1771. @@ -63,8 +57,6 @@ If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -76,6 +68,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/1/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Not+Quite+Lisp%22+%2D+Day+1+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F1&title=I%27ve+completed+%22Not+Quite+Lisp%22+%2D+Day+1+%2D+Advent+of+Code diff --git a/2015/day02/problem b/2015/day02/problem index 271d078..2d81364 100644 --- a/2015/day02/problem +++ b/2015/day02/problem @@ -1,52 +1,54 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 2: I Was Told There Would Be No Math --- - The elves are running low on wrapping paper, and so they need to submit an order for more. They - have a list of the dimensions (length l, width w, and height h) of each present, and only want - to order exactly as much as they need. + The elves are running low on wrapping paper, and so they need to submit an + order for more. They have a list of the dimensions (length l, width w, and + height h) of each present, and only want to order exactly as much as they + need. - Fortunately, every present is a box (a perfect right rectangular prism), which makes - calculating the required wrapping paper for each gift a little easier: find the surface area of - the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each - present: the area of the smallest side. + Fortunately, every present is a box (a perfect right rectangular prism), + which makes calculating the required wrapping paper for each gift a little + easier: find the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l. + The elves also need a little extra paper for each present: the area of the + smallest side. For example: - • A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping - paper plus 6 square feet of slack, for a total of 58 square feet. - • A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping - paper plus 1 square foot of slack, for a total of 43 square feet. + • A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square + feet of wrapping paper plus 6 square feet of slack, for a total of 58 + square feet. - All numbers in the elves' list are in feet. How many total square feet of wrapping paper should - they order? + • A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square + feet of wrapping paper plus 1 square foot of slack, for a total of 43 + square feet. + + All numbers in the elves' list are in feet. How many total square feet of + wrapping paper should they order? Your puzzle answer was 1588178. --- Part Two --- - The elves are also running low on ribbon. Ribbon is all the same width, so they only have to - worry about the length they need to order, which they would again like to be exact. + The elves are also running low on ribbon. Ribbon is all the same width, so + they only have to worry about the length they need to order, which they + would again like to be exact. - The ribbon required to wrap a present is the shortest distance around its sides, or the - smallest perimeter of any one face. Each present also requires a bow made out of ribbon as - well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of - the present. Don't ask how they tie the bow, though; they'll never tell. + The ribbon required to wrap a present is the shortest distance around its + sides, or the smallest perimeter of any one face. Each present also requires + a bow made out of ribbon as well; the feet of ribbon required for the + perfect bow is equal to the cubic feet of volume of the present. Don't ask + how they tie the bow, though; they'll never tell. For example: - • A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present - plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet. - • A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present - plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 feet. + • A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to + wrap the present plus 2*3*4 = 24 feet of ribbon for the bow, for a total + of 34 feet. + + • A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to + wrap the present plus 1*1*10 = 10 feet of ribbon for the bow, for a total + of 14 feet. How many total feet of ribbon should they order? @@ -54,12 +56,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -72,6 +73,3 @@ References . https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid . http://adventofcode.com/ . http://adventofcode.com/day/2/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22I+Was+Told+There+Would+Be+No+Math%22+%2D+Day+2+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F2&title=I%27ve+completed+%22I+Was+Told+There+Would+Be+No+Math%22+%2D+Day+2+%2D+Advent+of+Code diff --git a/2015/day03/problem b/2015/day03/problem index f456e3c..2a1fd5d 100644 --- a/2015/day03/problem +++ b/2015/day03/problem @@ -1,64 +1,64 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 3: Perfectly Spherical Houses in a Vacuum --- Santa is delivering presents to an infinite two-dimensional grid of houses. - He begins by delivering a present to the house at his starting location, and then an elf at the - North Pole calls him via radio and tells him where to move next. Moves are always exactly one - house to the north (^), south (v), east (>), or west (<). After each move, he delivers another - present to the house at his new location. + He begins by delivering a present to the house at his starting location, and + then an elf at the North Pole calls him via radio and tells him where to + move next. Moves are always exactly one house to the north (^), south (v), + east (>), or west (<). After each move, he delivers another present to the + house at his new location. - However, the elf back at the north pole has had a little too much eggnog, and so his directions - are a little off, and Santa ends up visiting some houses more than once. How many houses - receive at least one present? + However, the elf back at the north pole has had a little too much eggnog, + and so his directions are a little off, and Santa ends up visiting some + houses more than once. How many houses receive at least one present? For example: - • > delivers presents to 2 houses: one at the starting location, and one to the east. - • ^>v< delivers presents to 4 houses in a square, including twice to the house at his - starting/ending location. - • ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. + • > delivers presents to 2 houses: one at the starting location, and one + to the east. + + • ^>v< delivers presents to 4 houses in a square, including twice to the + house at his starting/ending location. + + • ^v^v^v^v^v delivers a bunch of presents to some very lucky children at + only 2 houses. Your puzzle answer was 2572. --- Part Two --- - The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, - to deliver presents with him. + The next year, to speed up the process, Santa creates a robot version of + himself, Robo-Santa, to deliver presents with him. - Santa and Robo-Santa start at the same location (delivering two presents to the same starting - house), then take turns moving based on instructions from the elf, who is eggnoggedly reading - from the same script as the previous year. + Santa and Robo-Santa start at the same location (delivering two presents to + the same starting house), then take turns moving based on instructions from + the elf, who is eggnoggedly reading from the same script as the previous + year. This year, how many houses receive at least one present? For example: - • ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south. - • ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they - started. - • ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and - Robo-Santa going the other. + • ^v delivers presents to 3 houses, because Santa goes north, and then + Robo-Santa goes south. + + • ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up + back where they started. + + • ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one + direction and Robo-Santa going the other. Your puzzle answer was 2631. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -70,6 +70,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/3/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Perfectly+Spherical+Houses+in+a+Vacuum%22+%2D+Day+3+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F3&title=I%27ve+completed+%22Perfectly+Spherical+Houses+in+a+Vacuum%22+%2D+Day+3+%2D+Advent+of+Code diff --git a/2015/day04/problem b/2015/day04/problem index f53aa0a..b1cd3fa 100644 --- a/2015/day04/problem +++ b/2015/day04/problem @@ -1,30 +1,25 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 4: The Ideal Stocking Stuffer --- - Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the - economically forward-thinking little girls and boys. + Santa needs help mining some AdventCoins (very similar to bitcoins) to use + as gifts for all the economically forward-thinking little girls and boys. - To do this, he needs to find MD5 hashes which, in hexadecimal, start with at least five zeroes. - The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a - number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no - leading zeroes: 1, 2, 3, ...) that produces such a hash. + To do this, he needs to find MD5 hashes which, in hexadecimal, start with at + least five zeroes. The input to the MD5 hash is some secret key (your puzzle + input, given below) followed by a number in decimal. To mine AdventCoins, + you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3, + ...) that produces such a hash. For example: - • If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043 - starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. - • If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash - starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like - 000006136ef.... + • If your secret key is abcdef, the answer is 609043, because the MD5 hash + of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the + lowest such number to do so. + + • If your secret key is pqrstuv, the lowest number it combines with to + make an MD5 hash starting with five zeroes is 1048970; that is, the MD5 + hash of pqrstuv1048970 looks like 000006136ef.... Your puzzle answer was 282749. @@ -36,12 +31,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. Your puzzle input was yzbqklnj. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -56,6 +50,3 @@ References . https://en.wikipedia.org/wiki/MD5 . https://en.wikipedia.org/wiki/Hexadecimal . http://adventofcode.com/ - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22The+Ideal+Stocking+Stuffer%22+%2D+Day+4+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F4&title=I%27ve+completed+%22The+Ideal+Stocking+Stuffer%22+%2D+Day+4+%2D+Advent+of+Code diff --git a/2015/day05/problem b/2015/day05/problem index b872a1e..895d783 100644 --- a/2015/day05/problem +++ b/2015/day05/problem @@ -1,33 +1,34 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 5: Doesn't He Have Intern-Elves For This? --- - Santa needs help figuring out which strings in his text file are naughty or nice. + Santa needs help figuring out which strings in his text file are naughty or + nice. A nice string is one with all of the following properties: - • It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou. - • It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or - aabbccdd (aa, bb, cc, or dd). - • It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the - other requirements. + • It contains at least three vowels (aeiou only), like aei, xazegov, or + aeiouaeiouaeiou. + + • It contains at least one letter that appears twice in a row, like xx, + abcdde (dd), or aabbccdd (aa, bb, cc, or dd). + + • It does not contain the strings ab, cd, pq, or xy, even if they are part + of one of the other requirements. For example: - • ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double - letter (...dd...), and none of the disallowed substrings. - • aaa is nice because it has at least three vowels and a double letter, even though the - letters used by different rules overlap. + • ugknbfddgicrmopn is nice because it has at least three vowels + (u...i...o...), a double letter (...dd...), and none of the disallowed + substrings. + + • aaa is nice because it has at least three vowels and a double letter, + even though the letters used by different rules overlap. + • jchzalrnumimnmhp is naughty because it has no double letter. + • haegwjzuvuyypxyu is naughty because it contains the string xy. + • dvszwmarrgswjxmb is naughty because it contains only one vowel. How many strings are nice? @@ -36,26 +37,33 @@ --- Part Two --- - Realizing the error of his ways, Santa has switched to a better model of determining whether a - string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. + Realizing the error of his ways, Santa has switched to a better model of + determining whether a string is naughty or nice. None of the old rules + apply, as they are all clearly ridiculous. Now, a nice string is one with all of the following properties: - • It contains a pair of any two letters that appears at least twice in the string without - overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). - • It contains at least one letter which repeats with exactly one letter between them, like - xyx, abcdefeghi (efe), or even aaa. + • It contains a pair of any two letters that appears at least twice in the + string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not + like aaa (aa, but it overlaps). + + • It contains at least one letter which repeats with exactly one letter + between them, like xyx, abcdefeghi (efe), or even aaa. For example: - • qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that - repeats with exactly one letter between them (zxz). - • xxyxx is nice because it has a pair that appears twice and a letter that repeats with one - between, even though the letters used by each rule overlap. - • uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter - between them. - • ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but - no pair that appears twice. + • qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) + and a letter that repeats with exactly one letter between them (zxz). + + • xxyxx is nice because it has a pair that appears twice and a letter that + repeats with one between, even though the letters used by each rule + overlap. + + • uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat + with a single letter between them. + + • ieodomkazucvgmuy is naughty because it has a repeating letter with one + between (odo), but no pair that appears twice. How many strings are nice under these new rules? @@ -63,12 +71,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -80,6 +87,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/5/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Doesn%27t+He+Have+Intern%2DElves+For+This%3F%22+%2D+Day+5+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F5&title=I%27ve+completed+%22Doesn%27t+He+Have+Intern%2DElves+For+This%3F%22+%2D+Day+5+%2D+Advent+of+Code diff --git a/2015/day06/problem b/2015/day06/problem index 7135358..dc7d80b 100644 --- a/2015/day06/problem +++ b/2015/day06/problem @@ -1,36 +1,33 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 6: Probably a Fire Hazard --- - Because your neighbors keep defeating you in the holiday house decorating contest year after - year, you've decided to deploy one million lights in a 1000x1000 grid. + Because your neighbors keep defeating you in the holiday house decorating + contest year after year, you've decided to deploy one million lights in a + 1000x1000 grid. - Furthermore, because you've been especially nice this year, Santa has mailed you instructions - on how to display the ideal lighting configuration. + Furthermore, because you've been especially nice this year, Santa has mailed + you instructions on how to display the ideal lighting configuration. - Lights in your grid are numbered from 0 to 999 in each direction; the lights at each corner are - at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or - toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents - opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore + Lights in your grid are numbered from 0 to 999 in each direction; the lights + at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions + include whether to turn on, turn off, or toggle various inclusive ranges + given as coordinate pairs. Each coordinate pair represents opposite corners + of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore refers to 9 lights in a 3x3 square. The lights all start turned off. - To defeat your neighbors this year, all you have to do is set up your lights by doing the - instructions Santa sent you in order. + To defeat your neighbors this year, all you have to do is set up your lights + by doing the instructions Santa sent you in order. For example: • turn on 0,0 through 999,999 would turn on (or leave on) every light. - • toggle 0,0 through 999,0 would toggle the first line of 1000 lights, turning off the ones - that were on, and turning on the ones that were off. - • turn off 499,499 through 500,500 would turn off (or leave off) the middle four lights. + + • toggle 0,0 through 999,0 would toggle the first line of 1000 lights, + turning off the ones that were on, and turning on the ones that were off. + + • turn off 499,499 through 500,500 would turn off (or leave off) the + middle four lights. After following the instructions, how many lights are lit? @@ -38,36 +35,40 @@ --- Part Two --- - You just finish implementing your winning light pattern when you realize you mistranslated - Santa's message from Ancient Nordic Elvish. + You just finish implementing your winning light pattern when you realize you + mistranslated Santa's message from Ancient Nordic Elvish. - The light grid you bought actually has individual brightness controls; each light can have a - brightness of zero or more. The lights all start at zero. + The light grid you bought actually has individual brightness controls; each + light can have a brightness of zero or more. The lights all start at zero. - The phrase turn on actually means that you should increase the brightness of those lights by 1. + The phrase turn on actually means that you should increase the brightness of + those lights by 1. - The phrase turn off actually means that you should decrease the brightness of those lights by - 1, to a minimum of zero. + The phrase turn off actually means that you should decrease the brightness + of those lights by 1, to a minimum of zero. - The phrase toggle actually means that you should increase the brightness of those lights by 2. + The phrase toggle actually means that you should increase the brightness of + those lights by 2. - What is the total brightness of all lights combined after following Santa's instructions? + What is the total brightness of all lights combined after following Santa's + instructions? For example: • turn on 0,0 through 0,0 would increase the total brightness by 1. - • toggle 0,0 through 999,999 would increase the total brightness by 2000000. + + • toggle 0,0 through 999,999 would increase the total brightness by + 2000000. Your puzzle answer was 14110788. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -79,6 +80,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/6/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Probably+a+Fire+Hazard%22+%2D+Day+6+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F6&title=I%27ve+completed+%22Probably+a+Fire+Hazard%22+%2D+Day+6+%2D+Advent+of+Code diff --git a/2015/day07/problem b/2015/day07/problem index 3d61605..856470c 100644 --- a/2015/day07/problem +++ b/2015/day07/problem @@ -1,39 +1,38 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 7: Some Assembly Required --- - This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! - Unfortunately, little Bobby is a little under the recommended age range, and he needs help - assembling the circuit. + This year, Santa brought little Bobby Tables a set of wires and bitwise + logic gates! Unfortunately, little Bobby is a little under the recommended + age range, and he needs help assembling the circuit. - Each wire has an identifier (some lowercase letters) and can carry a 16-bit signal (a number - from 0 to 65535). A signal is provided to each wire by a gate, another wire, or some specific - value. Each wire can only get a signal from one source, but can provide its signal to multiple - destinations. A gate provides no signal until all of its inputs have a signal. + Each wire has an identifier (some lowercase letters) and can carry a 16-bit + signal (a number from 0 to 65535). A signal is provided to each wire by a + gate, another wire, or some specific value. Each wire can only get a signal + from one source, but can provide its signal to multiple destinations. A gate + provides no signal until all of its inputs have a signal. - The included instructions booklet describes how to connect the parts together: x AND y -> z - means to connect wires x and y to an AND gate, and then connect its output to wire z. + The included instructions booklet describes how to connect the parts + together: x AND y -> z means to connect wires x and y to an AND gate, and + then connect its output to wire z. For example: • 123 -> x means that the signal 123 is provided to wire x. - • x AND y -> z means that the bitwise AND of wire x and wire y is provided to wire z. - • p LSHIFT 2 -> q means that the value from wire p is left-shifted by 2 and then provided to - wire q. - • NOT e -> f means that the bitwise complement of the value from wire e is provided to wire - f. - Other possible gates include OR (bitwise OR) and RSHIFT (right-shift). If, for some reason, - you'd like to emulate the circuit instead, almost all programming languages (for example, C, - JavaScript, or Python) provide operators for these gates. + • x AND y -> z means that the bitwise AND of wire x and wire y is provided + to wire z. + + • p LSHIFT 2 -> q means that the value from wire p is left-shifted by 2 + and then provided to wire q. + + • NOT e -> f means that the bitwise complement of the value from wire e is + provided to wire f. + + Other possible gates include OR (bitwise OR) and RSHIFT (right-shift). If, + for some reason, you'd like to emulate the circuit instead, almost all + programming languages (for example, C, JavaScript, or Python) provide + operators for these gates. For example, here is a simple circuit: @@ -57,26 +56,26 @@ x: 123 y: 456 - In little Bobby's kit's instructions booklet (provided as your puzzle input), what signal is - ultimately provided to wire a? + In little Bobby's kit's instructions booklet (provided as your puzzle + input), what signal is ultimately provided to wire a? Your puzzle answer was 16076. --- Part Two --- - Now, take the signal you got on wire a, override wire b to that signal, and reset the other - wires (including wire a). What new signal is ultimately provided to wire a? + Now, take the signal you got on wire a, override wire b to that signal, and + reset the other wires (including wire a). What new signal is ultimately + provided to wire a? Your puzzle answer was 2797. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -98,6 +97,3 @@ References . https://wiki.python.org/moin/BitwiseOperators . http://adventofcode.com/ . http://adventofcode.com/day/7/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Some+Assembly+Required%22+%2D+Day+7+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F7&title=I%27ve+completed+%22Some+Assembly+Required%22+%2D+Day+7+%2D+Advent+of+Code diff --git a/2015/day08/problem b/2015/day08/problem index 6f4ea4e..fc8e22b 100644 --- a/2015/day08/problem +++ b/2015/day08/problem @@ -1,68 +1,73 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 8: Matchsticks --- - Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital - copy. He needs to know how much space it will take up when stored. + Space on the sleigh is limited this year, and so Santa will be bringing his + list as a digital copy. He needs to know how much space it will take up when + stored. - It is common in many programming languages to provide a way to escape special characters in - strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in - very similar ways. + It is common in many programming languages to provide a way to escape + special characters in strings. For example, C, JavaScript, Perl, Python, and + even PHP handle special characters in very similar ways. - However, it is important to realize the difference between the number of characters in the code - representation of the string literal and the number of characters in the in-memory string - itself. + However, it is important to realize the difference between the number of + characters in the code representation of the string literal and the number + of characters in the in-memory string itself. For example: - • "" is 2 characters of code (the two double quotes), but the string contains zero - characters. + • "" is 2 characters of code (the two double quotes), but the string + contains zero characters. + • "abc" is 5 characters of code, but 3 characters in the string data. - • "aaa\"aaa" is 10 characters of code, but the string itself contains six "a" characters and - a single, escaped quote character, for a total of 7 characters in the string data. - • "\x27" is 6 characters of code, but the string itself contains just one - an apostrophe - ('), escaped using hexadecimal notation. - Santa's list is a file that contains many double-quoted string literals, one on each line. The - only escape sequences used are \\ (which represents a single backslash), \" (which represents a - lone double-quote character), and \x plus two hexadecimal characters (which represents a single - character with that ASCII code). + • "aaa\"aaa" is 10 characters of code, but the string itself contains six + "a" characters and a single, escaped quote character, for a total of 7 + characters in the string data. - Disregarding the whitespace in the file, what is the number of characters of code for string - literals minus the number of characters in memory for the values of the strings in total for - the entire file? + • "\x27" is 6 characters of code, but the string itself contains just one + - an apostrophe ('), escaped using hexadecimal notation. - For example, given the four strings above, the total number of characters of string code (2 + 5 - + 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 - = 11) is 23 - 11 = 12. + Santa's list is a file that contains many double-quoted string literals, one + on each line. The only escape sequences used are \\ (which represents a + single backslash), \" (which represents a lone double-quote character), and + \x plus two hexadecimal characters (which represents a single character with + that ASCII code). + + Disregarding the whitespace in the file, what is the number of characters of + code for string literals minus the number of characters in memory for the + values of the strings in total for the entire file? + + For example, given the four strings above, the total number of characters of + string code (2 + 5 + 10 + 6 = 23) minus the total number of characters in + memory for string values (0 + 3 + 7 + 1 = 11) is 23 - 11 = 12. Your puzzle answer was 1350. --- Part Two --- - Now, let's go the other way. In addition to finding the number of characters of code, you - should now encode each code representation as a new string and find the number of characters of - the new encoded representation, including the surrounding double quotes. + Now, let's go the other way. In addition to finding the number of characters + of code, you should now encode each code representation as a new string and + find the number of characters of the new encoded representation, including + the surrounding double quotes. For example: • "" encodes to "\"\"", an increase from 2 characters to 6. + • "abc" encodes to "\"abc\"", an increase from 5 characters to 9. - • "aaa\"aaa" encodes to "\"aaa\\\"aaa\"", an increase from 10 characters to 16. + + • "aaa\"aaa" encodes to "\"aaa\\\"aaa\"", an increase from 10 characters + to 16. + • "\x27" encodes to "\"\\x27\"", an increase from 6 characters to 11. - Your task is to find the total number of characters to represent the newly encoded strings - minus the number of characters of code in each original string literal. For example, for the - strings above, the total encoded length (6 + 9 + 16 + 11 = 42) minus the characters in the - original code representation (23, just like in the first part of this puzzle) is 42 - 23 = 19. + Your task is to find the total number of characters to represent the newly + encoded strings minus the number of characters of code in each original + string literal. For example, for the strings above, the total encoded length + (6 + 9 + 16 + 11 = 42) minus the characters in the original code + representation (23, just like in the first part of this puzzle) is 42 - 23 = + 19. Your puzzle answer was 2085. @@ -72,8 +77,6 @@ If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -90,6 +93,3 @@ References . http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double . http://adventofcode.com/ . http://adventofcode.com/day/8/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Matchsticks%22+%2D+Day+8+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F8&title=I%27ve+completed+%22Matchsticks%22+%2D+Day+8+%2D+Advent+of+Code diff --git a/2015/day09/problem b/2015/day09/problem index c34e75f..b9f234b 100644 --- a/2015/day09/problem +++ b/2015/day09/problem @@ -1,21 +1,14 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 9: All in a Single Night --- Every year, Santa manages to deliver all of his presents in a single night. - This year, however, he has some new locations to visit; his elves have provided him the - distances between every pair of locations. He can start and end at any two (different) - locations he wants, but he must visit each location exactly once. What is the shortest distance - he can travel to achieve this? + This year, however, he has some new locations to visit; his elves have + provided him the distances between every pair of locations. He can start and + end at any two (different) locations he wants, but he must visit each + location exactly once. What is the shortest distance he can travel to + achieve this? For example, given the following distances: @@ -32,8 +25,8 @@ Belfast -> Dublin -> London = 605 Belfast -> London -> Dublin = 982 - The shortest of these is London -> Dublin -> Belfast = 605, and so the answer is 605 in this - example. + The shortest of these is London -> Dublin -> Belfast = 605, and so the + answer is 605 in this example. What is the distance of the shortest route? @@ -41,14 +34,14 @@ --- Part Two --- - The next year, just to show off, Santa decides to take the route with the longest distance - instead. + The next year, just to show off, Santa decides to take the route with the + longest distance instead. - He can still start and end at any two (different) locations he wants, and he still must visit - each location exactly once. + He can still start and end at any two (different) locations he wants, and he + still must visit each location exactly once. - For example, given the distances above, the longest route would be 982 via (for example) Dublin - -> London -> Belfast. + For example, given the distances above, the longest route would be 982 via + (for example) Dublin -> London -> Belfast. What is the distance of the longest route? @@ -56,12 +49,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -73,6 +65,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/9/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22All+in+a+Single+Night%22+%2D+Day+9+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F9&title=I%27ve+completed+%22All+in+a+Single+Night%22+%2D+Day+9+%2D+Advent+of+Code diff --git a/2015/day10/problem b/2015/day10/problem index 135cb11..f90c39c 100644 --- a/2015/day10/problem +++ b/2015/day10/problem @@ -1,22 +1,16 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 10: Elves Look, Elves Say --- - Today, the Elves are playing a game called look-and-say. They take turns making sequences by - reading aloud the previous sequence and using that reading as the next sequence. For example, - 211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s). + Today, the Elves are playing a game called look-and-say. They take turns + making sequences by reading aloud the previous sequence and using that + reading as the next sequence. For example, 211 is read as "one two, two + ones", which becomes 1221 (1 2, 2 1s). - Look-and-say sequences are generated iteratively, using the previous value as input for the - next step. For each step, take the previous value, and replace each run of digits (like 111) - with the number of digits (3) followed by the digit itself (1). + Look-and-say sequences are generated iteratively, using the previous value + as input for the next step. For each step, take the previous value, and + replace each run of digits (like 111) with the number of digits (3) followed + by the digit itself (1). For example: @@ -26,18 +20,18 @@ • 1211 becomes 111221 (one 1, one 2, and two 1s). • 111221 becomes 312211 (three 1s, two 2s, and one 1). - Starting with the digits in your puzzle input, apply this process 40 times. What is the length - of the result? + Starting with the digits in your puzzle input, apply this process 40 times. + What is the length of the result? Your puzzle answer was 360154. --- Part Two --- - Neat, right? You might also enjoy hearing John Conway talking about this sequence (that's - Conway of Conway's Game of Life fame). + Neat, right? You might also enjoy hearing John Conway talking about this + sequence (that's Conway of Conway's Game of Life fame). - Now, starting again with the digits in your puzzle input, apply this process 50 times. What is - the length of the new result? + Now, starting again with the digits in your puzzle input, apply this process + 50 times. What is the length of the new result? Your puzzle answer was 5103798. @@ -47,8 +41,6 @@ Your puzzle input was 1113122113. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -61,6 +53,3 @@ References . https://en.wikipedia.org/wiki/Look-and-say_sequence . https://www.youtube.com/watch?v=ea7lJkEhytA . http://adventofcode.com/ - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Elves+Look%2C+Elves+Say%22+%2D+Day+10+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F10&title=I%27ve+completed+%22Elves+Look%2C+Elves+Say%22+%2D+Day+10+%2D+Advent+of+Code diff --git a/2015/day11/problem b/2015/day11/problem index 2b16b52..7774987 100644 --- a/2015/day11/problem +++ b/2015/day11/problem @@ -1,48 +1,52 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 11: Corporate Policy --- Santa's previous password expired, and he needs help choosing a new one. - To help him remember his new password after the old one expires, Santa has devised a method of - coming up with a password based on the previous one. Corporate policy dictates that passwords - must be exactly eight lowercase letters (for security reasons), so he finds his new password by - incrementing his old password string repeatedly until it is valid. + To help him remember his new password after the old one expires, Santa has + devised a method of coming up with a password based on the previous one. + Corporate policy dictates that passwords must be exactly eight lowercase + letters (for security reasons), so he finds his new password by incrementing + his old password string repeatedly until it is valid. - Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so on. Increase the - rightmost letter one step; if it was z, it wraps around to a, and repeat with the next letter - to the left until one doesn't wrap around. + Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so + on. Increase the rightmost letter one step; if it was z, it wraps around to + a, and repeat with the next letter to the left until one doesn't wrap + around. - Unfortunately for Santa, a new Security-Elf recently started, and he has imposed some - additional password requirements: + Unfortunately for Santa, a new Security-Elf recently started, and he has + imposed some additional password requirements: - • Passwords must include one increasing straight of at least three letters, like abc, bcd, - cde, and so on, up to xyz. They cannot skip letters; abd doesn't count. - • Passwords may not contain the letters i, o, or l, as these letters can be mistaken for - other characters and are therefore confusing. - • Passwords must contain at least two different, non-overlapping pairs of letters, like aa, - bb, or zz. + • Passwords must include one increasing straight of at least three + letters, like abc, bcd, cde, and so on, up to xyz. They cannot skip + letters; abd doesn't count. + + • Passwords may not contain the letters i, o, or l, as these letters can + be mistaken for other characters and are therefore confusing. + + • Passwords must contain at least two different, non-overlapping pairs of + letters, like aa, bb, or zz. For example: - • hijklmmn meets the first requirement (because it contains the straight hij) but fails the - second requirement requirement (because it contains i and l). - • abbceffg meets the third requirement (because it repeats bb and ff) but fails the first - requirement. - • abbcegjk fails the third requirement, because it only has one double letter (bb). - • The next password after abcdefgh is abcdffaa. - • The next password after ghijklmn is ghjaabcc, because you eventually skip all the passwords - that start with ghi..., since i is not allowed. + • hijklmmn meets the first requirement (because it contains the straight + hij) but fails the second requirement requirement (because it contains i + and l). - Given Santa's current password (your puzzle input), what should his next password be? + • abbceffg meets the third requirement (because it repeats bb and ff) but + fails the first requirement. + + • abbcegjk fails the third requirement, because it only has one double + letter (bb). + + • The next password after abcdefgh is abcdffaa. + + • The next password after ghijklmn is ghjaabcc, because you eventually + skip all the passwords that start with ghi..., since i is not allowed. + + Given Santa's current password (your puzzle input), what should his next + password be? Your puzzle answer was hepxxyzz. @@ -54,12 +58,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. Your puzzle input was hepxcrrq. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -70,6 +73,3 @@ References . http://adventofcode.com/settings . http://adventofcode.com/auth/logout . http://adventofcode.com/ - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Corporate+Policy%22+%2D+Day+11+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F11&title=I%27ve+completed+%22Corporate+Policy%22+%2D+Day+11+%2D+Advent+of+Code diff --git a/2015/day12/problem b/2015/day12/problem index 4943b8d..1a51e71 100644 --- a/2015/day12/problem +++ b/2015/day12/problem @@ -1,27 +1,24 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 12: JSAbacusFramework.io --- - Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, - their accounting software uses a peculiar storage format. That's where you come in. + Santa's Accounting-Elves need help balancing the books after a recent order. + Unfortunately, their accounting software uses a peculiar storage format. + That's where you come in. - They have a JSON document which contains a variety of things: arrays ([1,2,3]), objects - ({"a":1, "b":2}), numbers, and strings. Your first job is to simply find all of the numbers - throughout the document and add them together. + They have a JSON document which contains a variety of things: arrays + ([1,2,3]), objects ({"a":1, "b":2}), numbers, and strings. Your first job is + to simply find all of the numbers throughout the document and add them + together. For example: • [1,2,3] and {"a":2,"b":4} both have a sum of 6. + • [[[3]]] and {"a":{"b":4},"c":-1} both have a sum of 3. + • {"a":[-1,1]} and [-1,{"a":1}] both have a sum of 0. + • [] and {} both have a sum of 0. You will not encounter any strings containing numbers. @@ -32,27 +29,31 @@ --- Part Two --- - Uh oh - the Accounting-Elves have realized that they double-counted everything red. + Uh oh - the Accounting-Elves have realized that they double-counted + everything red. - Ignore any object (and all of its children) which has any property with the value "red". Do - this only for objects ({...}), not arrays ([...]). + Ignore any object (and all of its children) which has any property with the + value "red". Do this only for objects ({...}), not arrays ([...]). • [1,2,3] still has a sum of 6. - • [1,{"c":"red","b":2},3] now has a sum of 4, because the middle object is ignored. - • {"d":"red","e":[1,2,3,4],"f":5} now has a sum of 0, because the entire structure is + + • [1,{"c":"red","b":2},3] now has a sum of 4, because the middle object is ignored. + + • {"d":"red","e":[1,2,3,4],"f":5} now has a sum of 0, because the entire + structure is ignored. + • [1,"red",5] has a sum of 6, because "red" in an array has no effect. Your puzzle answer was 87842. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -65,6 +66,3 @@ References . http://json.org/ . http://adventofcode.com/ . http://adventofcode.com/day/12/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22JSAbacusFramework%2Eio%22+%2D+Day+12+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F12&title=I%27ve+completed+%22JSAbacusFramework%2Eio%22+%2D+Day+12+%2D+Advent+of+Code diff --git a/2015/day13/problem b/2015/day13/problem index d983dbb..99ed0ee 100644 --- a/2015/day13/problem +++ b/2015/day13/problem @@ -1,26 +1,20 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 13: Knights of the Dinner Table --- - In years past, the holiday feast with your family hasn't gone so well. Not everyone gets along! - This year, you resolve, will be different. You're going to find the optimal seating arrangement - and avoid all those awkward conversations. + In years past, the holiday feast with your family hasn't gone so well. Not + everyone gets along! This year, you resolve, will be different. You're going + to find the optimal seating arrangement and avoid all those awkward + conversations. - You start by writing up a list of everyone invited and the amount their happiness would - increase or decrease if they were to find themselves sitting next to each other person. You - have a circular table that will be just big enough to fit everyone comfortably, and so each - person will have exactly two neighbors. + You start by writing up a list of everyone invited and the amount their + happiness would increase or decrease if they were to find themselves sitting + next to each other person. You have a circular table that will be just big + enough to fit everyone comfortably, and so each person will have exactly two + neighbors. - For example, suppose you have only four attendees planned, and you calculate their potential - happiness as follows: + For example, suppose you have only four attendees planned, and you calculate + their potential happiness as follows: Alice would gain 54 happiness units by sitting next to Bob. Alice would lose 79 happiness units by sitting next to Carol. @@ -35,13 +29,14 @@ David would lose 7 happiness units by sitting next to Bob. David would gain 41 happiness units by sitting next to Carol. - Then, if you seat Alice next to David, Alice would lose 2 happiness units (because David talks - so much), but David would gain 46 happiness units (because Alice is such a good listener), for - a total change of 44. + Then, if you seat Alice next to David, Alice would lose 2 happiness units + (because David talks so much), but David would gain 46 happiness units + (because Alice is such a good listener), for a total change of 44. - If you continue around the table, you could then seat Bob next to Alice (Bob gains 83, Alice - gains 54). Finally, seat Carol, who sits next to Bob (Carol gains 60, Bob loses 7) and David - (Carol gains 55, David gains 41). The arrangement looks like this: + If you continue around the table, you could then seat Bob next to Alice (Bob + gains 83, Alice gains 54). Finally, seat Carol, who sits next to Bob (Carol + gains 60, Bob loses 7) and David (Carol gains 55, David gains 41). The + arrangement looks like this: +41 +46 +55 David -2 @@ -49,37 +44,37 @@ +60 Bob +54 -7 +83 - After trying every other seating arrangement in this hypothetical scenario, you find that this - one is the most optimal, with a total change in happiness of 330. + After trying every other seating arrangement in this hypothetical scenario, + you find that this one is the most optimal, with a total change in happiness + of 330. - What is the total change in happiness for the optimal seating arrangement of the actual guest - list? + What is the total change in happiness for the optimal seating arrangement of + the actual guest list? Your puzzle answer was 733. --- Part Two --- - In all the commotion, you realize that you forgot to seat yourself. At this point, you're - pretty apathetic toward the whole thing, and your happiness wouldn't really go up or down - regardless of who you sit next to. You assume everyone else would be just as ambivalent about - sitting next to you, too. + In all the commotion, you realize that you forgot to seat yourself. At this + point, you're pretty apathetic toward the whole thing, and your happiness + wouldn't really go up or down regardless of who you sit next to. You assume + everyone else would be just as ambivalent about sitting next to you, too. - So, add yourself to the list, and give all happiness relationships that involve you a score of - 0. + So, add yourself to the list, and give all happiness relationships that + involve you a score of 0. - What is the total change in happiness for the optimal seating arrangement that actually - includes yourself? + What is the total change in happiness for the optimal seating arrangement + that actually includes yourself? Your puzzle answer was 725. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -91,6 +86,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/13/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Knights+of+the+Dinner+Table%22+%2D+Day+13+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F13&title=I%27ve+completed+%22Knights+of+the+Dinner+Table%22+%2D+Day+13+%2D+Advent+of+Code diff --git a/2015/day14/problem b/2015/day14/problem index 9e85a62..76e453d 100644 --- a/2015/day14/problem +++ b/2015/day14/problem @@ -1,62 +1,62 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 14: Reindeer Olympics --- - This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally - to recover their energy. Santa would like to know which of his reindeer is fastest, and so he - has them race. + This year is the Reindeer Olympics! Reindeer can fly at high speeds, but + must rest occasionally to recover their energy. Santa would like to know + which of his reindeer is fastest, and so he has them race. - Reindeer can only either be flying (always at their top speed) or resting (not moving at all), - and always spend whole seconds in either state. + Reindeer can only either be flying (always at their top speed) or resting + (not moving at all), and always spend whole seconds in either state. For example, suppose you have the following Reindeer: - • Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds. - • Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. + • Comet can fly 14 km/s for 10 seconds, but then must rest for 127 + seconds. - After one second, Comet has gone 14 km, while Dancer has gone 16 km. After ten seconds, Comet - has gone 140 km, while Dancer has gone 160 km. On the eleventh second, Comet begins resting - (staying at 140 km), and Dancer continues on for a total distance of 176 km. On the 12th - second, both reindeer are resting. They continue to rest until the 138th second, when Comet - flies for another ten seconds. On the 174th second, Dancer flies for another 11 seconds. + • Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 + seconds. - In this example, after the 1000th second, both reindeer are resting, and Comet is in the lead - at 1120 km (poor Dancer has only gotten 1056 km by that point). So, in this situation, Comet - would win (if the race ended at 1000 seconds). + After one second, Comet has gone 14 km, while Dancer has gone 16 km. After + ten seconds, Comet has gone 140 km, while Dancer has gone 160 km. On the + eleventh second, Comet begins resting (staying at 140 km), and Dancer + continues on for a total distance of 176 km. On the 12th second, both + reindeer are resting. They continue to rest until the 138th second, when + Comet flies for another ten seconds. On the 174th second, Dancer flies for + another 11 seconds. - Given the descriptions of each reindeer (in your puzzle input), after exactly 2503 seconds, - what distance has the winning reindeer traveled? + In this example, after the 1000th second, both reindeer are resting, and + Comet is in the lead at 1120 km (poor Dancer has only gotten 1056 km by that + point). So, in this situation, Comet would win (if the race ended at 1000 + seconds). + + Given the descriptions of each reindeer (in your puzzle input), after + exactly 2503 seconds, what distance has the winning reindeer traveled? Your puzzle answer was 2660. --- Part Two --- - Seeing how reindeer move in bursts, Santa decides he's not pleased with the old scoring system. + Seeing how reindeer move in bursts, Santa decides he's not pleased with the + old scoring system. - Instead, at the end of each second, he awards one point to the reindeer currently in the lead. - (If there are multiple reindeer tied for the lead, they each get one point.) He keeps the - traditional 2503 second time limit, of course, as doing otherwise would be entirely ridiculous. + Instead, at the end of each second, he awards one point to the reindeer + currently in the lead. (If there are multiple reindeer tied for the lead, + they each get one point.) He keeps the traditional 2503 second time limit, + of course, as doing otherwise would be entirely ridiculous. - Given the example reindeer from above, after the first second, Dancer is in the lead and gets - one point. He stays in the lead until several seconds into Comet's second burst: after the - 140th second, Comet pulls into the lead and gets his first point. Of course, since Dancer had - been in the lead for the 139 seconds before that, he has accumulated 139 points by the 140th - second. + Given the example reindeer from above, after the first second, Dancer is in + the lead and gets one point. He stays in the lead until several seconds into + Comet's second burst: after the 140th second, Comet pulls into the lead and + gets his first point. Of course, since Dancer had been in the lead for the + 139 seconds before that, he has accumulated 139 points by the 140th second. - After the 1000th second, Dancer has accumulated 689 points, while poor Comet, our old champion, - only has 312. So, with the new scoring system, Dancer would win (if the race ended at 1000 - seconds). + After the 1000th second, Dancer has accumulated 689 points, while poor + Comet, our old champion, only has 312. So, with the new scoring system, + Dancer would win (if the race ended at 1000 seconds). - Again given the descriptions of each reindeer (in your puzzle input), after exactly 2503 - seconds, how many points does the winning reindeer have? + Again given the descriptions of each reindeer (in your puzzle input), after + exactly 2503 seconds, how many points does the winning reindeer have? Your puzzle answer was 1256. @@ -66,8 +66,6 @@ If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -79,6 +77,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/14/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Reindeer+Olympics%22+%2D+Day+14+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F14&title=I%27ve+completed+%22Reindeer+Olympics%22+%2D+Day+14+%2D+Advent+of+Code diff --git a/2015/day15/problem b/2015/day15/problem index 52b98df..eaf397c 100644 --- a/2015/day15/problem +++ b/2015/day15/problem @@ -1,81 +1,81 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 15: Science for Hungry People --- - Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to - do is find the right balance of ingredients. + Today, you set out on the task of perfecting your milk-dunking cookie + recipe. All you have to do is find the right balance of ingredients. - Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a list of the - remaining ingredients you could use to finish the recipe (your puzzle input) and their - properties per teaspoon: + Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a + list of the remaining ingredients you could use to finish the recipe (your + puzzle input) and their properties per teaspoon: • capacity (how well it helps the cookie absorb milk) + • durability (how well it keeps the cookie intact when full of milk) + • flavor (how tasty it makes the cookie) + • texture (how it improves the feel of the cookie) + • calories (how many calories it adds to the cookie) - You can only measure ingredients in whole-teaspoon amounts accurately, and you have to be - accurate so you can reproduce your results in the future. The total score of a cookie can be - found by adding up each of the properties (negative totals become 0) and then multiplying - together everything except calories. + You can only measure ingredients in whole-teaspoon amounts accurately, and + you have to be accurate so you can reproduce your results in the future. The + total score of a cookie can be found by adding up each of the properties + (negative totals become 0) and then multiplying together everything except + calories. For instance, suppose you have these two ingredients: Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8 Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3 - Then, choosing to use 44 teaspoons of butterscotch and 56 teaspoons of cinnamon (because the - amounts of each ingredient must add up to 100) would result in a cookie with the following - properties: + Then, choosing to use 44 teaspoons of butterscotch and 56 teaspoons of + cinnamon (because the amounts of each ingredient must add up to 100) would + result in a cookie with the following properties: • A capacity of 44*-1 + 56*2 = 68 • A durability of 44*-2 + 56*3 = 80 • A flavor of 44*6 + 56*-2 = 152 • A texture of 44*3 + 56*-1 = 76 - Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now) results in a total - score of 62842880, which happens to be the best score possible given these ingredients. If any - properties had produced a negative total, it would have instead become zero, causing the whole - score to multiply to zero. + Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now) + results in a total score of 62842880, which happens to be the best score + possible given these ingredients. If any properties had produced a negative + total, it would have instead become zero, causing the whole score to + multiply to zero. - Given the ingredients in your kitchen and their properties, what is the total score of the - highest-scoring cookie you can make? + Given the ingredients in your kitchen and their properties, what is the + total score of the highest-scoring cookie you can make? Your puzzle answer was 18965440. --- Part Two --- - Your cookie recipe becomes wildly popular! Someone asks if you can make another recipe that has - exactly 500 calories per cookie (so they can use it as a meal replacement). Keep the rest of - your award-winning process the same (100 teaspoons, same ingredients, same scoring system). + Your cookie recipe becomes wildly popular! Someone asks if you can make + another recipe that has exactly 500 calories per cookie (so they can use it + as a meal replacement). Keep the rest of your award-winning process the same + (100 teaspoons, same ingredients, same scoring system). - For example, given the ingredients above, if you had instead selected 40 teaspoons of - butterscotch and 60 teaspoons of cinnamon (which still adds to 100), the total calorie count - would be 40*8 + 60*3 = 500. The total score would go down, though: only 57600000, the best you - can do in such trying circumstances. + For example, given the ingredients above, if you had instead selected 40 + teaspoons of butterscotch and 60 teaspoons of cinnamon (which still adds to + 100), the total calorie count would be 40*8 + 60*3 = 500. The total score + would go down, though: only 57600000, the best you can do in such trying + circumstances. - Given the ingredients in your kitchen and their properties, what is the total score of the - highest-scoring cookie you can make with a calorie total of 500? + Given the ingredients in your kitchen and their properties, what is the + total score of the highest-scoring cookie you can make with a calorie total + of 500? Your puzzle answer was 15862900. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -87,6 +87,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/15/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F15&title=I%27ve+completed+%22Science+for+Hungry+People%22+%2D+Day+15+%2D+Advent+of+Code diff --git a/2015/day16/problem b/2015/day16/problem index c0e29bd..bc7fc4c 100644 --- a/2015/day16/problem +++ b/2015/day16/problem @@ -1,39 +1,42 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 16: Aunt Sue --- - Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. - However, there's a small problem: she signed it "From, Aunt Sue". + Your Aunt Sue has given you a wonderful gift, and you'd like to send her a + thank you card. However, there's a small problem: she signed it "From, Aunt + Sue". You have 500 Aunts named "Sue". - So, to avoid sending the card to the wrong person, you need to figure out which Aunt Sue (which - you conveniently number 1 to 500, for sanity) gave you the gift. You open the present and, as - luck would have it, good ol' Aunt Sue got you a My First Crime Scene Analysis Machine! Just - what you wanted. Or needed, as the case may be. + So, to avoid sending the card to the wrong person, you need to figure out + which Aunt Sue (which you conveniently number 1 to 500, for sanity) gave you + the gift. You open the present and, as luck would have it, good ol' Aunt Sue + got you a My First Crime Scene Analysis Machine! Just what you wanted. Or + needed, as the case may be. - The My First Crime Scene Analysis Machine (MFCSAM for short) can detect a few specific - compounds in a given sample, as well as how many distinct kinds of those compounds there are. - According to the instructions, these are what the MFCSAM can detect: + The My First Crime Scene Analysis Machine (MFCSAM for short) can detect a + few specific compounds in a given sample, as well as how many distinct kinds + of those compounds there are. According to the instructions, these are what + the MFCSAM can detect: • children, by human DNA age analysis. + • cats. It doesn't differentiate individual breeds. - • Several seemingly random breeds of dog: samoyeds, pomeranians, akitas, and vizslas. + + • Several seemingly random breeds of dog: samoyeds, pomeranians, akitas, + and vizslas. + • goldfish. No other kinds of fish. + • trees, all in one group. + • cars, presumably by exhaust or gasoline or something. + • perfumes, which is handy, since many of your Aunts Sue wear a few kinds. - In fact, many of your Aunts Sue have many of these. You put the wrapping from the gift into the - MFCSAM. It beeps inquisitively at you a few times and then prints out a message on ticker tape: + In fact, many of your Aunts Sue have many of these. You put the wrapping + from the gift into the MFCSAM. It beeps inquisitively at you a few times and + then prints out a message on ticker tape: children: 3 cats: 7 @@ -46,8 +49,8 @@ cars: 2 perfumes: 1 - You make a list of the things you can remember about each Aunt Sue. Things missing from your - list aren't zero - you simply don't remember the value. + You make a list of the things you can remember about each Aunt Sue. Things + missing from your list aren't zero - you simply don't remember the value. What is the number of the Sue that got you the gift? @@ -55,14 +58,16 @@ --- Part Two --- - As you're about to send the thank you note, something in the MFCSAM's instructions catches your - eye. Apparently, it has an outdated retroencabulator, and so the output from the machine isn't - exact values - some of them indicate ranges. + As you're about to send the thank you note, something in the MFCSAM's + instructions catches your eye. Apparently, it has an outdated + retroencabulator, and so the output from the machine isn't exact values - + some of them indicate ranges. - In particular, the cats and trees readings indicates that there are greater than that many (due - to the unpredictable nuclear decay of cat dander and tree pollen), while the pomeranians and - goldfish readings indicate that there are fewer than that many (due to the modial interaction - of magnetoreluctance). + In particular, the cats and trees readings indicates that there are greater + than that many (due to the unpredictable nuclear decay of cat dander and + tree pollen), while the pomeranians and goldfish readings indicate that + there are fewer than that many (due to the modial interaction of + magnetoreluctance). What is the number of the real Aunt Sue? @@ -70,12 +75,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -93,6 +97,3 @@ References . https://www.youtube.com/watch?v=RXJKdh1KZ0w . http://adventofcode.com/ . http://adventofcode.com/day/16/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Aunt+Sue%22+%2D+Day+16+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F16&title=I%27ve+completed+%22Aunt+Sue%22+%2D+Day+16+%2D+Advent+of+Code diff --git a/2015/day17/problem b/2015/day17/problem index f15ca9a..6f9943a 100644 --- a/2015/day17/problem +++ b/2015/day17/problem @@ -1,53 +1,46 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 17: No Such Thing as Too Much --- - The elves bought too much eggnog again - 150 liters this time. To fit it all into your - refrigerator, you'll need to move it into smaller containers. You take an inventory of the - capacities of the available containers. + The elves bought too much eggnog again - 150 liters this time. To fit it all + into your refrigerator, you'll need to move it into smaller containers. You + take an inventory of the capacities of the available containers. - For example, suppose you have containers of size 20, 15, 10, 5, and 5 liters. If you need to - store 25 liters, there are four ways to do it: + For example, suppose you have containers of size 20, 15, 10, 5, and 5 + liters. If you need to store 25 liters, there are four ways to do it: • 15 and 10 • 20 and 5 (the first 5) • 20 and 5 (the second 5) • 15, 5, and 5 - Filling all containers entirely, how many different combinations of containers can exactly fit - all 150 liters of eggnog? + Filling all containers entirely, how many different combinations of + containers can exactly fit all 150 liters of eggnog? Your puzzle answer was 1304. --- Part Two --- - While playing with all the containers in the kitchen, another load of eggnog arrives! The - shipping and receiving department is requesting as many containers as you can spare. + While playing with all the containers in the kitchen, another load of eggnog + arrives! The shipping and receiving department is requesting as many + containers as you can spare. - Find the minimum number of containers that can exactly fit all 150 liters of eggnog. How many - different ways can you fill that number of containers and still hold exactly 150 litres? + Find the minimum number of containers that can exactly fit all 150 liters of + eggnog. How many different ways can you fill that number of containers and + still hold exactly 150 litres? - In the example above, the minimum number of containers was two. There were three ways to use - that many containers, and so the answer there would be 3. + In the example above, the minimum number of containers was two. There were + three ways to use that many containers, and so the answer there would be 3. Your puzzle answer was 18. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -59,6 +52,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/17/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F17&title=I%27ve+completed+%22No+Such+Thing+as+Too+Much%22+%2D+Day+17+%2D+Advent+of+Code diff --git a/2015/day18/problem b/2015/day18/problem index 01dec05..478bcde 100644 --- a/2015/day18/problem +++ b/2015/day18/problem @@ -1,31 +1,27 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 18: Like a GIF For Your Yard --- - After the million lights incident, the fire code has gotten stricter: now, at most ten thousand - lights are allowed. You arrange them in a 100x100 grid. + After the million lights incident, the fire code has gotten stricter: now, + at most ten thousand lights are allowed. You arrange them in a 100x100 grid. - Never one to let you down, Santa again mails you instructions on the ideal lighting - configuration. With so few lights, he says, you'll have to resort to animation. + Never one to let you down, Santa again mails you instructions on the ideal + lighting configuration. With so few lights, he says, you'll have to resort + to animation. - Start by setting your lights to the included initial configuration (your puzzle input). A # - means "on", and a . means "off". + Start by setting your lights to the included initial configuration (your + puzzle input). A # means "on", and a . means "off". - Then, animate your grid in steps, where each step decides the next configuration based on the - current one. Each light's next state (either on or off) depends on its current state and the - current states of the eight lights adjacent to it (including diagonals). Lights on the edge of - the grid might have fewer than eight neighbors; the missing ones always count as "off". + Then, animate your grid in steps, where each step decides the next + configuration based on the current one. Each light's next state (either on + or off) depends on its current state and the current states of the eight + lights adjacent to it (including diagonals). Lights on the edge of the grid + might have fewer than eight neighbors; the missing ones always count as + "off". - For example, in a simplified 6x6 grid, the light marked A has the neighbors numbered 1 through - 8, and the light marked B, which is on an edge, only has the neighbors marked 1 through 5: + For example, in a simplified 6x6 grid, the light marked A has the neighbors + numbered 1 through 8, and the light marked B, which is on an edge, only has + the neighbors marked 1 through 5: 1B5... 234... @@ -34,14 +30,17 @@ ..8A4. ..765. - The state a light should have next is based on its current state (on or off) plus the number of - neighbors that are on: + The state a light should have next is based on its current state (on or off) + plus the number of neighbors that are on: - • A light which is on stays on when 2 or 3 neighbors are on, and turns off otherwise. - • A light which is off turns on if exactly 3 neighbors are on, and stays off otherwise. + • A light which is on stays on when 2 or 3 neighbors are on, and turns off + otherwise. - All of the lights update simultaneously; they all consider the same current state before moving - to the next. + • A light which is off turns on if exactly 3 neighbors are on, and stays + off otherwise. + + All of the lights update simultaneously; they all consider the same current + state before moving to the next. Here's a few steps from an example configuration of another 6x6 grid: @@ -87,17 +86,18 @@ After 4 steps, this example has four lights on. - In your grid of 100x100 lights, given your initial configuration, how many lights are on after - 100 steps? + In your grid of 100x100 lights, given your initial configuration, how many + lights are on after 100 steps? Your puzzle answer was 814. --- Part Two --- - You flip the instructions over; Santa goes on to point out that this is all just an - implementation of Conway's Game of Life. At least, it was, until you notice that something's - wrong with the grid of lights you bought: four lights, one in each corner, are stuck on and - can't be turned off. The example above will actually run like this: + You flip the instructions over; Santa goes on to point out that this is all + just an implementation of Conway's Game of Life. At least, it was, until you + notice that something's wrong with the grid of lights you bought: four + lights, one in each corner, are stuck on and can't be turned off. The + example above will actually run like this: Initial state: ##.#.# @@ -149,19 +149,19 @@ After 5 steps, this example now has 17 lights on. - In your grid of 100x100 lights, given your initial configuration, but with the four corners - always in the on state, how many lights are on after 100 steps? + In your grid of 100x100 lights, given your initial configuration, but with + the four corners always in the on state, how many lights are on after 100 + steps? Your puzzle answer was 924. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -175,6 +175,3 @@ References . https://en.wikipedia.org/wiki/Conway's_Game_of_Life . http://adventofcode.com/ . http://adventofcode.com/day/18/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F18&title=I%27ve+completed+%22Like+a+GIF+For+Your+Yard%22+%2D+Day+18+%2D+Advent+of+Code diff --git a/2015/day19/problem b/2015/day19/problem index 534594d..8b14a67 100644 --- a/2015/day19/problem +++ b/2015/day19/problem @@ -1,38 +1,32 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 19: Medicine for Rudolph --- - Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very brightly, and he needs - medicine. + Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very + brightly, and he needs medicine. - Red-Nosed Reindeer biology isn't similar to regular reindeer biology; Rudolph is going to need - custom-made medicine. Unfortunately, Red-Nosed Reindeer chemistry isn't similar to regular - reindeer chemistry, either. + Red-Nosed Reindeer biology isn't similar to regular reindeer biology; + Rudolph is going to need custom-made medicine. Unfortunately, Red-Nosed + Reindeer chemistry isn't similar to regular reindeer chemistry, either. - The North Pole is equipped with a Red-Nosed Reindeer nuclear fusion/fission plant, capable of - constructing any Red-Nosed Reindeer molecule you need. It works by starting with some input - molecule and then doing a series of replacements, one per step, until it has the right - molecule. + The North Pole is equipped with a Red-Nosed Reindeer nuclear fusion/fission + plant, capable of constructing any Red-Nosed Reindeer molecule you need. It + works by starting with some input molecule and then doing a series of + replacements, one per step, until it has the right molecule. - However, the machine has to be calibrated before it can be used. Calibration involves - determining the number of molecules that can be generated in one step from a given starting - point. + However, the machine has to be calibrated before it can be used. Calibration + involves determining the number of molecules that can be generated in one + step from a given starting point. - For example, imagine a simpler machine that supports only the following replacements: + For example, imagine a simpler machine that supports only the following + replacements: H => HO H => OH O => HH - Given the replacements above and starting with HOH, the following molecules could be generated: + Given the replacements above and starting with HOH, the following molecules + could be generated: • HOOH (via H => HO on the first H). • HOHO (via H => HO on the second H). @@ -40,25 +34,28 @@ • HOOH (via H => OH on the second H). • HHHH (via O => HH). - So, in the example above, there are 4 distinct molecules (not five, because HOOH appears twice) - after one replacement from HOH. Santa's favorite molecule, HOHOHO, can become 7 distinct - molecules (over nine replacements: six from H, and three from O). + So, in the example above, there are 4 distinct molecules (not five, because + HOOH appears twice) after one replacement from HOH. Santa's favorite + molecule, HOHOHO, can become 7 distinct molecules (over nine replacements: + six from H, and three from O). - The machine replaces without regard for the surrounding characters. For example, given the - string H2O, the transition H => OO would result in OO2O. + The machine replaces without regard for the surrounding characters. For + example, given the string H2O, the transition H => OO would result in OO2O. - Your puzzle input describes all of the possible replacements and, at the bottom, the medicine - molecule for which you need to calibrate the machine. How many distinct molecules can be - created after all the different ways you can do one replacement on the medicine molecule? + Your puzzle input describes all of the possible replacements and, at the + bottom, the medicine molecule for which you need to calibrate the machine. + How many distinct molecules can be created after all the different ways you + can do one replacement on the medicine molecule? Your puzzle answer was 518. --- Part Two --- - Now that the machine is calibrated, you're ready to begin molecule fabrication. + Now that the machine is calibrated, you're ready to begin molecule + fabrication. - Molecule fabrication always begins with just a single electron, e, and applying replacements - one at a time, just like the ones during calibration. + Molecule fabrication always begins with just a single electron, e, and + applying replacements one at a time, just like the ones during calibration. For example, suppose you have the following replacements: @@ -68,29 +65,29 @@ H => OH O => HH - If you'd like to make HOH, you start with e, and then make the following replacements: + If you'd like to make HOH, you start with e, and then make the following + replacements: • e => O to get O • O => HH to get HH • H => OH (on the second H) to get HOH - So, you could make HOH after 3 steps. Santa's favorite molecule, HOHOHO, can be made in 6 - steps. + So, you could make HOH after 3 steps. Santa's favorite molecule, HOHOHO, can + be made in 6 steps. - How long will it take to make the medicine? Given the available replacements and the medicine - molecule in your puzzle input, what is the fewest number of steps to go from e to the medicine - molecule? + How long will it take to make the medicine? Given the available replacements + and the medicine molecule in your puzzle input, what is the fewest number of + steps to go from e to the medicine molecule? Your puzzle answer was 200. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -102,6 +99,3 @@ References . http://adventofcode.com/auth/logout . http://adventofcode.com/ . http://adventofcode.com/day/19/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Medicine+for+Rudolph%22+%2D+Day+19+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F19&title=I%27ve+completed+%22Medicine+for+Rudolph%22+%2D+Day+19+%2D+Advent+of+Code diff --git a/2015/day20/problem b/2015/day20/problem index 6461ebd..be7019d 100644 --- a/2015/day20/problem +++ b/2015/day20/problem @@ -1,26 +1,25 @@ - Advent of Code - - br0xen 40* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 20: Infinite Elves and Infinite Houses --- - To keep the Elves busy, Santa has them deliver some presents by hand, door-to-door. He sends - them down a street with infinite houses numbered sequentially: 1, 2, 3, 4, 5, and so on. + To keep the Elves busy, Santa has them deliver some presents by hand, + door-to-door. He sends them down a street with infinite houses numbered + sequentially: 1, 2, 3, 4, 5, and so on. - Each Elf is assigned a number, too, and delivers presents to houses based on that number: + Each Elf is assigned a number, too, and delivers presents to houses based on + that number: - • The first Elf (number 1) delivers presents to every house: 1, 2, 3, 4, 5, .... - • The second Elf (number 2) delivers presents to every second house: 2, 4, 6, 8, 10, .... - • Elf number 3 delivers presents to every third house: 3, 6, 9, 12, 15, .... + • The first Elf (number 1) delivers presents to every house: 1, 2, 3, 4, + 5, .... - There are infinitely many Elves, numbered starting with 1. Each Elf delivers presents equal to - ten times his or her number at each house. + • The second Elf (number 2) delivers presents to every second house: 2, 4, + 6, 8, 10, .... + + • Elf number 3 delivers presents to every third house: 3, 6, 9, 12, 15, + .... + + There are infinitely many Elves, numbered starting with 1. Each Elf delivers + presents equal to ten times his or her number at each house. So, the first nine houses on the street end up like this: @@ -34,34 +33,34 @@ House 8 got 150 presents. House 9 got 130 presents. - The first house gets 10 presents: it is visited only by Elf 1, which delivers 1 * 10 = 10 - presents. The fourth house gets 70 presents, because it is visited by Elves 1, 2, and 4, for a - total of 10 + 20 + 40 = 70 presents. + The first house gets 10 presents: it is visited only by Elf 1, which + delivers 1 * 10 = 10 presents. The fourth house gets 70 presents, because it + is visited by Elves 1, 2, and 4, for a total of 10 + 20 + 40 = 70 presents. - What is the lowest house number of the house to get at least as many presents as the number in - your puzzle input? + What is the lowest house number of the house to get at least as many + presents as the number in your puzzle input? Your puzzle answer was 831600. --- Part Two --- - The Elves decide they don't want to visit an infinite number of houses. Instead, each Elf will - stop after delivering presents to 50 houses. To make up for it, they decide to deliver presents - equal to eleven times their number at each house. + The Elves decide they don't want to visit an infinite number of houses. + Instead, each Elf will stop after delivering presents to 50 houses. To make + up for it, they decide to deliver presents equal to eleven times their + number at each house. - With these changes, what is the new lowest house number of the house to get at least as many - presents as the number in your puzzle input? + With these changes, what is the new lowest house number of the house to get + at least as many presents as the number in your puzzle input? Your puzzle answer was 884520. Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. Your puzzle input was 36000000. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -72,6 +71,3 @@ References . http://adventofcode.com/settings . http://adventofcode.com/auth/logout . http://adventofcode.com/ - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22Infinite+Elves+and+Infinite+Houses%22+%2D+Day+20+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F20&title=I%27ve+completed+%22Infinite+Elves+and+Infinite+Houses%22+%2D+Day+20+%2D+Advent+of+Code diff --git a/2015/day21/problem b/2015/day21/problem index a3aa5b8..0113803 100644 --- a/2015/day21/problem +++ b/2015/day21/problem @@ -10,22 +10,25 @@ --- Day 21: RPG Simulator 20XX --- - Little Henry Case got a new video game for Christmas. It's an RPG, and he's stuck on a boss. - He needs to know what equipment to buy at the shop. He hands you the controller. + Little Henry Case got a new video game for Christmas. It's an RPG, and he's + stuck on a boss. He needs to know what equipment to buy at the shop. He + hands you the controller. - In this game, the player (you) and the enemy (the boss) take turns attacking. The player - always goes first. Each attack reduces the opponent's hit points by at least 1. The first - character at or below 0 hit points loses. + In this game, the player (you) and the enemy (the boss) take turns + attacking. The player always goes first. Each attack reduces the opponent's + hit points by at least 1. The first character at or below 0 hit points + loses. - Damage dealt by an attacker each turn is equal to the attacker's damage score minus the - defender's armor score. An attacker always does at least 1 damage. So, if the attacker has a - damage score of 8, and the defender has an armor score of 3, the defender loses 5 hit points. - If the defender had an armor score of 300, the defender would still lose 1 hit point. + Damage dealt by an attacker each turn is equal to the attacker's damage + score minus the defender's armor score. An attacker always does at least 1 + damage. So, if the attacker has a damage score of 8, and the defender has an + armor score of 3, the defender loses 5 hit points. If the defender had an + armor score of 300, the defender would still lose 1 hit point. - Your damage score and armor score both start at zero. They can be increased by buying items in - exchange for gold. You start with no items and have as much gold as you need. Your total - damage or armor is equal to the sum of those stats from all of your items. You have 100 hit - points. + Your damage score and armor score both start at zero. They can be increased + by buying items in exchange for gold. You start with no items and have as + much gold as you need. Your total damage or armor is equal to the sum of + those stats from all of your items. You have 100 hit points. Here is what the item shop is selling: @@ -51,12 +54,13 @@ Defense +2 40 0 2 Defense +3 80 0 3 - You must buy exactly one weapon; no dual-wielding. Armor is optional, but you can't use more - than one. You can buy 0-2 rings (at most one for each hand). You must use any items you buy. - The shop only has one of each item, so you can't buy, for example, two rings of Damage +3. + You must buy exactly one weapon; no dual-wielding. Armor is optional, but + you can't use more than one. You can buy 0-2 rings (at most one for each + hand). You must use any items you buy. The shop only has one of each item, + so you can't buy, for example, two rings of Damage +3. - For example, suppose you have 8 hit points, 5 damage, and 5 armor, and that the boss has 12 - hit points, 7 damage, and 2 armor: + For example, suppose you have 8 hit points, 5 damage, and 5 armor, and that + the boss has 12 hit points, 7 damage, and 2 armor: • The player deals 5-2 = 3 damage; the boss goes down to 9 hit points. • The boss deals 7-5 = 2 damage; the player goes down to 6 hit points. @@ -68,15 +72,16 @@ In this scenario, the player wins! (Barely.) - You have 100 hit points. The boss's actual stats are in your puzzle input. What is the least - amount of gold you can spend and still win the fight? + You have 100 hit points. The boss's actual stats are in your puzzle input. + What is the least amount of gold you can spend and still win the fight? Your puzzle answer was 91. --- Part Two --- - Turns out the shopkeeper is working with the boss, and can persuade you to buy whatever items - he wants. The other rules still apply, and he still only has one of each item. + Turns out the shopkeeper is working with the boss, and can persuade you to + buy whatever items he wants. The other rules still apply, and he still only + has one of each item. What is the most amount of gold you can spend and still lose the fight? @@ -84,12 +89,11 @@ Both parts of this puzzle are complete! They provide two gold stars: ** - At this point, you should return to your advent calendar and try another puzzle. + At this point, you should return to your advent calendar and try another + puzzle. If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -103,6 +107,3 @@ References . https://en.wikipedia.org/wiki/Game_controller . http://adventofcode.com/ . http://adventofcode.com/day/21/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F21&title=I%27ve+completed+%22RPG+Simulator+20XX%22+%2D+Day+21+%2D+Advent+of+Code diff --git a/2015/day22/problem b/2015/day22/problem index b6325f4..4d3577b 100644 --- a/2015/day22/problem +++ b/2015/day22/problem @@ -1,50 +1,52 @@ - Advent of Code - - br0xen 44* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 22: Wizard Simulator 20XX --- - Little Henry Case decides that defeating bosses with swords and stuff is boring. Now he's - playing the game with a wizard. Of course, he gets stuck on another boss and needs your help - again. + Little Henry Case decides that defeating bosses with swords and stuff is + boring. Now he's playing the game with a wizard. Of course, he gets stuck on + another boss and needs your help again. - In this version, combat still proceeds with the player and the boss taking alternating turns. - The player still goes first. Now, however, you don't get any equipment; instead, you must - choose one of your spells to cast. The first character at or below 0 hit points loses. + In this version, combat still proceeds with the player and the boss taking + alternating turns. The player still goes first. Now, however, you don't get + any equipment; instead, you must choose one of your spells to cast. The + first character at or below 0 hit points loses. - Since you're a wizard, you don't get to wear armor, and you can't attack normally. However, - since you do magic damage, your opponent's armor is ignored, and so the boss effectively has - zero armor as well. As before, if armor (from a spell, in this case) would reduce damage below - 1, it becomes 1 instead - that is, the boss' attacks always deal at least 1 damage. + Since you're a wizard, you don't get to wear armor, and you can't attack + normally. However, since you do magic damage, your opponent's armor is + ignored, and so the boss effectively has zero armor as well. As before, if + armor (from a spell, in this case) would reduce damage below 1, it becomes 1 + instead - that is, the boss' attacks always deal at least 1 damage. - On each of your turns, you must select one of your spells to cast. If you cannot afford to - cast any spell, you lose. Spells cost mana; you start with 500 mana, but have no maximum - limit. You must have enough mana to cast a spell, and its cost is immediately deducted when - you cast it. Your spells are Magic Missile, Drain, Shield, Poison, and Recharge. + On each of your turns, you must select one of your spells to cast. If you + cannot afford to cast any spell, you lose. Spells cost mana; you start with + 500 mana, but have no maximum limit. You must have enough mana to cast a + spell, and its cost is immediately deducted when you cast it. Your spells + are Magic Missile, Drain, Shield, Poison, and Recharge. • Magic Missile costs 53 mana. It instantly does 4 damage. - • Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit points. - • Shield costs 113 mana. It starts an effect that lasts for 6 turns. While it is active, - your armor is increased by 7. - • Poison costs 173 mana. It starts an effect that lasts for 6 turns. At the start of each - turn while it is active, it deals the boss 3 damage. - • Recharge costs 229 mana. It starts an effect that lasts for 5 turns. At the start of each - turn while it is active, it gives you 101 new mana. - Effects all work the same way. Effects apply at the start of both the player's turns and the - boss' turns. Effects are created with a timer (the number of turns they last); at the start of - each turn, after they apply any effect they have, their timer is decreased by one. If this - decreases the timer to zero, the effect ends. You cannot cast a spell that would start an - effect which is already active. However, effects can be started on the same turn they end. + • Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit + points. - For example, suppose the player has 10 hit points and 250 mana, and that the boss has 13 hit - points and 8 damage: + • Shield costs 113 mana. It starts an effect that lasts for 6 turns. While + it is active, your armor is increased by 7. + + • Poison costs 173 mana. It starts an effect that lasts for 6 turns. At + the start of each turn while it is active, it deals the boss 3 damage. + + • Recharge costs 229 mana. It starts an effect that lasts for 5 turns. At + the start of each turn while it is active, it gives you 101 new mana. + + Effects all work the same way. Effects apply at the start of both the + player's turns and the boss' turns. Effects are created with a timer (the + number of turns they last); at the start of each turn, after they apply any + effect they have, their timer is decreased by one. If this decreases the + timer to zero, the effect ends. You cannot cast a spell that would start an + effect which is already active. However, effects can be started on the same + turn they end. + + For example, suppose the player has 10 hit points and 250 mana, and that the + boss has 13 hit points and 8 damage: -- Player turn -- - Player has 10 hit points, 0 armor, 250 mana @@ -68,7 +70,8 @@ - Boss has 3 hit points Poison deals 3 damage. This kills the boss, and the player wins. - Now, suppose the same initial conditions, except that the boss has 14 hit points instead: + Now, suppose the same initial conditions, except that the boss has 14 hit + points instead: -- Player turn -- - Player has 10 hit points, 0 armor, 250 mana @@ -135,27 +138,45 @@ - Boss has 2 hit points Poison deals 3 damage. This kills the boss, and the player wins. - You start with 50 hit points and 500 mana points. The boss's actual stats are in your puzzle - input. What is the least amount of mana you can spend and still win the fight? (Do not include - mana recharge effects as "spending" negative mana.) + You start with 50 hit points and 500 mana points. The boss's actual stats + are in your puzzle input. What is the least amount of mana you can spend and + still win the fight? (Do not include mana recharge effects as "spending" + negative mana.) - To begin, get your puzzle input. + Your puzzle answer was 1824. - Answer: _____________________ [ [Submit] ] +--- Part Two --- - You can also [Shareon Twitter Google+ Reddit] this puzzle. + On the next run through the game, you increase the difficulty to hard. + + At the start of each player turn (before any other effects apply), you lose + 1 hit point. If this brings you to or below 0 hit points, you lose. + + With the same starting stats for you and the boss, what is the least amount + of mana you can spend and still win the fight? + + Your puzzle answer was 1937. + + 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 . http://adventofcode.com/ - . http://adventofcode.com/about - . http://adventofcode.com/stats - . http://adventofcode.com/leaderboard - . http://adventofcode.com/settings - . http://adventofcode.com/auth/logout - . http://adventofcode.com/day/21 - . http://adventofcode.com/day/22/input - . https://twitter.com/intent/tweet?text=%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22&title=%22Wizard+Simulator+20XX%22+%2D+Day+22+%2D+Advent+of+Code + . http://adventofcode.com/2015/about + . http://adventofcode.com/2015/support + . http://adventofcode.com/2015/events + . http://adventofcode.com/2015/settings + . http://adventofcode.com/2015/auth/logout + . http://adventofcode.com/2015 + . http://adventofcode.com/2015 + . http://adventofcode.com/2015/leaderboard + . http://adventofcode.com/2015/stats + . http://adventofcode.com/2015/sponsors + . http://adventofcode.com/2015/day/21 + . http://adventofcode.com/2015 + . http://adventofcode.com/2015/day/22/input diff --git a/2015/day23/problem b/2015/day23/problem index 5866c5c..67de623 100644 --- a/2015/day23/problem +++ b/2015/day23/problem @@ -1,48 +1,54 @@ - Advent of Code - - br0xen 43* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 23: Opening the Turing Lock --- - Little Jane Marie just got her very first computer for Christmas from some unknown benefactor. - It comes with instructions and an example program, but the computer itself seems to be - malfunctioning. She's curious what the program does, and would like you to help her run it. + Little Jane Marie just got her very first computer for Christmas from some + unknown benefactor. It comes with instructions and an example program, but + the computer itself seems to be malfunctioning. She's curious what the + program does, and would like you to help her run it. - The manual explains that the computer supports two registers and six instructions (truly, it - goes on to remind the reader, a state-of-the-art technology). The registers are named a and b, - can hold any non-negative integer, and begin with a value of 0. The instructions are as - follows: + The manual explains that the computer supports two registers and six + instructions (truly, it goes on to remind the reader, a state-of-the-art + technology). The registers are named a and b, can hold any non-negative + integer, and begin with a value of 0. The instructions are as follows: - • hlf r sets register r to half its current value, then continues with the next instruction. - • tpl r sets register r to triple its current value, then continues with the next - instruction. - • inc r increments register r, adding 1 to it, then continues with the next instruction. - • jmp offset is a jump; it continues with the instruction offset away relative to itself. - • jie r, offset is like jmp, but only jumps if register r is even ("jump if even"). - • jio r, offset is like jmp, but only jumps if register r is 1 ("jump if one", not odd). + • hlf r sets register r to half its current value, then continues with the + next instruction. - All three jump instructions work with an offset relative to that instruction. The offset is - always written with a prefix + or - to indicate the direction of the jump (forward or - backward, respectively). For example, jmp +1 would simply continue with the next instruction, - while jmp +0 would continuously jump back to itself forever. + • tpl r sets register r to triple its current value, then continues with + the next instruction. - The program exits when it tries to run an instruction beyond the ones defined. + • inc r increments register r, adding 1 to it, then continues with the + next instruction. - For example, this program sets a to 2, because the jio instruction causes it to skip the tpl - instruction: + • jmp offset is a jump; it continues with the instruction offset away + relative to itself. + + • jie r, offset is like jmp, but only jumps if register r is even ("jump + if even"). + + • jio r, offset is like jmp, but only jumps if register r is 1 ("jump if + one", not odd). + + All three jump instructions work with an offset relative to that + instruction. The offset is always written with a prefix + or - to indicate + the direction of the jump (forward or backward, respectively). For example, + jmp +1 would simply continue with the next instruction, while jmp +0 would + continuously jump back to itself forever. + + The program exits when it tries to run an instruction beyond the ones + defined. + + For example, this program sets a to 2, because the jio instruction causes it + to skip the tpl instruction: inc a jio a, +2 tpl a inc a - What is the value in register b when the program in your puzzle input is finished executing? + What is the value in register b when the program in your puzzle input is + finished executing? Your puzzle answer was 255. @@ -50,15 +56,14 @@ --- Part Two --- - The unknown benefactor is very thankful for releasi-- er, helping little Jane Marie with her - computer. Definitely not to distract you, what is the value in register b after the program is - finished executing if register a starts as 1 instead? + The unknown benefactor is very thankful for releasi-- er, helping little + Jane Marie with her computer. Definitely not to distract you, what is the + value in register b after the program is finished executing if register a + starts as 1 instead? Although it hasn't changed, you can still get your puzzle input. - Answer: _____________________ [ [Submit] ] - - You can also [Shareon Twitter Google+ Reddit] this puzzle. + Answer: 334 References @@ -73,6 +78,3 @@ References . https://en.wikipedia.org/wiki/Instruction_set . https://en.wikipedia.org/wiki/Natural_number . http://adventofcode.com/day/23/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Opening+the+Turing+Lock%22+%2D+Day+23+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F23&title=I%27ve+completed+Part+One+of+%22Opening+the+Turing+Lock%22+%2D+Day+23+%2D+Advent+of+Code diff --git a/2015/day24/problem b/2015/day24/problem index 5b77d93..0fea76f 100644 --- a/2015/day24/problem +++ b/2015/day24/problem @@ -1,42 +1,39 @@ - Advent of Code - - br0xen 50* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 24: It Hangs in the Balance --- - It's Christmas Eve, and Santa is loading up the sleigh for this year's deliveries. However, - there's one small problem: he can't get the sleigh to balance. If it isn't balanced, he can't - defy physics, and nobody gets presents this year. + It's Christmas Eve, and Santa is loading up the sleigh for this year's + deliveries. However, there's one small problem: he can't get the sleigh to + balance. If it isn't balanced, he can't defy physics, and nobody gets + presents this year. No pressure. - Santa has provided you a list of the weights of every package he needs to fit on the sleigh. - The packages need to be split into three groups of exactly the same weight, and every package - has to fit. The first group goes in the passenger compartment of the sleigh, and the second - and third go in containers on either side. Only when all three groups weigh exactly the same + Santa has provided you a list of the weights of every package he needs to + fit on the sleigh. The packages need to be split into three groups of + exactly the same weight, and every package has to fit. The first group goes + in the passenger compartment of the sleigh, and the second and third go in + containers on either side. Only when all three groups weigh exactly the same amount will the sleigh be able to fly. Defying physics has rules, you know! - Of course, that's not the only problem. The first group - the one going in the passenger - compartment - needs as few packages as possible so that Santa has some legroom left over. It - doesn't matter how many packages are in either of the other two groups, so long as all of the - groups weigh the same. + Of course, that's not the only problem. The first group - the one going in + the passenger compartment - needs as few packages as possible so that Santa + has some legroom left over. It doesn't matter how many packages are in + either of the other two groups, so long as all of the groups weigh the same. - Furthermore, Santa tells you, if there are multiple ways to arrange the packages such that the - fewest possible are in the first group, you need to choose the way where the first group has - the smallest quantum entanglement to reduce the chance of any "complications". The quantum - entanglement of a group of packages is the product of their weights, that is, the value you - get when you multiply their weights together. Only consider quantum entanglement if the first - group has the fewest possible number of packages in it and all groups weigh the same amount. + Furthermore, Santa tells you, if there are multiple ways to arrange the + packages such that the fewest possible are in the first group, you need to + choose the way where the first group has the smallest quantum entanglement + to reduce the chance of any "complications". The quantum entanglement of a + group of packages is the product of their weights, that is, the value you + get when you multiply their weights together. Only consider quantum + entanglement if the first group has the fewest possible number of packages + in it and all groups weigh the same amount. - For example, suppose you have ten packages with weights 1 through 5 and 7 through 11. For this - situation, some of the unique first groups, their quantum entanglements, and a way to divide - the remaining packages are as follows: + For example, suppose you have ten packages with weights 1 through 5 and 7 + through 11. For this situation, some of the unique first groups, their + quantum entanglements, and a way to divide the remaining packages are as + follows: Group 1; Group 2; Group 3 11 9 (QE= 99); 10 8 2; 7 5 4 3 1 @@ -53,13 +50,15 @@ 8 5 4 3 (QE=480); 11 9; 10 7 2 1 7 5 4 3 1 (QE=420); 11 9; 10 8 2 - Of these, although 10 9 1 has the smallest quantum entanglement (90), the configuration with - only two packages, 11 9, in the passenger compartment gives Santa the most legroom and wins. - In this situation, the quantum entanglement for the ideal configuration is therefore 99. Had - there been two configurations with only two packages in the first group, the one with the + Of these, although 10 9 1 has the smallest quantum entanglement (90), the + configuration with only two packages, 11 9, in the passenger compartment + gives Santa the most legroom and wins. In this situation, the quantum + entanglement for the ideal configuration is therefore 99. Had there been two + configurations with only two packages in the first group, the one with the smaller quantum entanglement would be chosen. - What is the quantum entanglement of the first group of packages in the ideal configuration? + What is the quantum entanglement of the first group of packages in the ideal + configuration? Your puzzle answer was 10439961859. @@ -69,11 +68,12 @@ "Ho ho ho", Santa muses to himself. "I forgot the trunk". - Balance the sleigh again, but this time, separate the packages into four groups instead of - three. The other constraints still apply. + Balance the sleigh again, but this time, separate the packages into four + groups instead of three. The other constraints still apply. - Given the example packages above, this would be some of the new unique first groups, their - quantum entanglements, and one way to divide the remaining packages: + Given the example packages above, this would be some of the new unique first + groups, their quantum entanglements, and one way to divide the remaining + packages: 11 4 (QE=44); 10 5; 9 3 2 1; 8 7 10 5 (QE=50); 11 4; 9 3 2 1; 8 7 @@ -82,12 +82,12 @@ 9 3 2 1 (QE=54); 11 4; 10 5; 8 7 8 7 (QE=56); 11 4; 10 5; 9 3 2 1 - Of these, there are three arrangements that put the minimum (two) number of packages in the - first group: 11 4, 10 5, and 8 7. Of these, 11 4 has the lowest quantum entanglement, and so - it is selected. + Of these, there are three arrangements that put the minimum (two) number of + packages in the first group: 11 4, 10 5, and 8 7. Of these, 11 4 has the + lowest quantum entanglement, and so it is selected. - Now, what is the quantum entanglement of the first group of packages in the ideal - configuration? + Now, what is the quantum entanglement of the first group of packages in the + ideal configuration? Your puzzle answer was 72050269. @@ -97,8 +97,6 @@ If you still want to see it, you can get your puzzle input. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -111,6 +109,3 @@ References . https://en.wikipedia.org/wiki/Product_%28mathematics%29 . http://adventofcode.com/ . http://adventofcode.com/day/24/input - . https://twitter.com/intent/tweet?text=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&title=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code diff --git a/2015/day25/problem b/2015/day25/problem index 88990ea..91b57a5 100644 --- a/2015/day25/problem +++ b/2015/day25/problem @@ -1,38 +1,33 @@ - Advent of Code - - br0xen 46* - - • [About] - • [Stats] - • [Leaderboard] - • [Settings] - • [Log out] +Advent of Code --- Day 25: Let It Snow --- - Merry Christmas! Santa is booting up his weather machine; looks like you might get a white - Christmas after all. + Merry Christmas! Santa is booting up his weather machine; looks like you + might get a white Christmas after all. - The weather machine beeps! On the console of the machine is a copy protection message asking - you to enter a code from the instruction manual. Apparently, it refuses to run unless you give - it that code. No problem; you'll just look up the code in the-- + The weather machine beeps! On the console of the machine is a copy + protection message asking you to enter a code from the instruction manual. + Apparently, it refuses to run unless you give it that code. No problem; + you'll just look up the code in the-- "Ho ho ho", Santa ponders aloud. "I can't seem to find the manual." - You look up the support number for the manufacturer and give them a call. Good thing, too - - that 49th star wasn't going to earn itself. + You look up the support number for the manufacturer and give them a call. + Good thing, too - that 49th star wasn't going to earn itself. - "Oh, that machine is quite old!", they tell you. "That model went out of support six minutes - ago, and we just finished shredding all of the manuals. I bet we can find you the code - generation algorithm, though." + "Oh, that machine is quite old!", they tell you. "That model went out of + support six minutes ago, and we just finished shredding all of the manuals. + I bet we can find you the code generation algorithm, though." - After putting you on hold for twenty minutes (your call is very important to them, it reminded - you repeatedly), they finally find an engineer that remembers how the code system works. + After putting you on hold for twenty minutes (your call is very important to + them, it reminded you repeatedly), they finally find an engineer that + remembers how the code system works. - The codes are printed on an infinite sheet of paper, starting in the top-left corner. The - codes are filled in by diagonals: starting with the first row with an empty first box, the - codes are filled in diagonally up and to the right. This process repeats until the infinite - paper is covered. So, the first few codes are filled in in this order: + The codes are printed on an infinite sheet of paper, starting in the + top-left corner. The codes are filled in by diagonals: starting with the + first row with an empty first box, the codes are filled in diagonally up and + to the right. This process repeats until the infinite paper is covered. So, + the first few codes are filled in in this order: | 1 2 3 4 5 6 ---+---+---+---+---+---+---+ @@ -43,19 +38,21 @@ 5 | 11 17 6 | 16 - For example, the 12th code would be written to row 4, column 2; the 15th code would be written - to row 1, column 5. + For example, the 12th code would be written to row 4, column 2; the 15th + code would be written to row 1, column 5. - The voice on the other end of the phone continues with how the codes are actually generated. - The first code is 20151125. After that, each code is generated by taking the previous one, - multiplying it by 252533, and then keeping the remainder from dividing that value by 33554393. + The voice on the other end of the phone continues with how the codes are + actually generated. The first code is 20151125. After that, each code is + generated by taking the previous one, multiplying it by 252533, and then + keeping the remainder from dividing that value by 33554393. - So, to find the second code (which ends up in row 2, column 1), start with the previous value, - 20151125. Multiply it by 252533 to get 5088824049625. Then, divide that by 33554393, which - leaves a remainder of 31916031. That remainder is the second code. + So, to find the second code (which ends up in row 2, column 1), start with + the previous value, 20151125. Multiply it by 252533 to get 5088824049625. + Then, divide that by 33554393, which leaves a remainder of 31916031. That + remainder is the second code. - "Oh!", says the voice. "It looks like we missed a scrap from one of the manuals. Let me read - it to you." You write down his numbers: + "Oh!", says the voice. "It looks like we missed a scrap from one of the + manuals. Let me read it to you." You write down his numbers: | 1 2 3 4 5 6 ---+---------+---------+---------+---------+---------+---------+ @@ -66,12 +63,13 @@ 5 | 77061 17552253 28094349 6899651 9250759 31663883 6 | 33071741 6796745 25397450 24659492 1534922 27995004 - "Now remember", the voice continues, "that's not even all of the first few numbers; for - example, you're missing the one at 7,1 that would come before 6,2. But, it should be enough to - let your-- oh, it's time for lunch! Bye!" The call disconnects. + "Now remember", the voice continues, "that's not even all of the first few + numbers; for example, you're missing the one at 7,1 that would come before + 6,2. But, it should be enough to let your-- oh, it's time for lunch! Bye!" + The call disconnects. - Santa looks nervous. Your puzzle input contains the message on the machine's console. What - code do you give the machine? + Santa looks nervous. Your puzzle input contains the message on the machine's + console. What code do you give the machine? Your puzzle answer was 19980801. @@ -79,16 +77,16 @@ --- Part Two --- - The machine springs to life, then falls silent again. It beeps. "Insufficient fuel", the - console reads. "Fifty stars are required before proceeding. One star is available." + The machine springs to life, then falls silent again. It beeps. + "Insufficient fuel", the console reads. "Fifty stars are required before + proceeding. One star is available." - ..."one star is available"? You check the fuel tank; sure enough, a lone star sits at the - bottom, awaiting its friends. Looks like you need to provide 49 yourself. + ..."one star is available"? You check the fuel tank; sure enough, a lone + star sits at the bottom, awaiting its friends. Looks like you need to + provide 49 yourself. You don't have enough stars to start the machine, though. You need x more. - You can also [Shareon Twitter Google+ Reddit] this puzzle. - References Visible links @@ -101,6 +99,3 @@ References . http://adventofcode.com/day/1 . https://en.wikipedia.org/wiki/Copy_protection#Early_video_games . https://en.wikipedia.org/wiki/Cantor's_diagonal_argument - . https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Let+It+Snow%22+%2D+Day+25+%2D+Advent+of+Code&url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25&related=ericwastl&hashtags=AdventOfCode - . https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25 - . http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F25&title=I%27ve+completed+Part+One+of+%22Let+It+Snow%22+%2D+Day+25+%2D+Advent+of+Code diff --git a/2016/day01/problem b/2016/day01/problem index 32ed6c5..ddd42c4 100644 --- a/2016/day01/problem +++ b/2016/day01/problem @@ -2,38 +2,55 @@ Advent of Code --- Day 1: No Time for a Taxicab --- - Santa's sleigh uses a very high-precision clock to guide its movements, and the clock's oscillator is regulated by stars. Unfortunately, the stars have been stolen... by the Easter Bunny. To save Christmas, Santa needs you to + Santa's sleigh uses a very high-precision clock to guide its movements, and + the clock's oscillator is regulated by stars. Unfortunately, the stars have + been stolen... by the Easter Bunny. To save Christmas, Santa needs you to retrieve 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! + 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're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start here, and nobody had time - to work them out further. + You're airdropped near Easter Bunny Headquarters in a city somewhere. + "Near", unfortunately, is as close as you can get - the instructions on the + Easter Bunny Recruiting Document the Elves intercepted start here, and + nobody had time to work them out further. - The Document indicates that you should start at the given coordinates (where you just landed) and face North. Then, follow the provided sequence: either turn left (L) or right (R) 90 degrees, then walk forward the given number of + The Document indicates that you should start at the given coordinates (where + you just landed) and face North. Then, follow the provided sequence: either + turn left (L) or right (R) 90 degrees, then walk forward the given number of blocks, ending at a new intersection. - There's no time to follow such ridiculous instructions on foot, though, so you take a moment and work out the destination. Given that you can only walk on the street grid of the city, how far is the shortest path to the destination? + There's no time to follow such ridiculous instructions on foot, though, so + you take a moment and work out the destination. Given that you can only walk + on the street grid of the city, how far is the shortest path to the + destination? For example: - • Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away. - • R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away. + • Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 + blocks away. + + • R2, R2, R2 leaves you 2 blocks due South of your starting position, + which is 2 blocks away. + • R5, L5, R5, R3 leaves you 12 blocks away. How many blocks away is Easter Bunny HQ? - Your puzzle answer was ___. + Your puzzle answer was 243. --- Part Two --- - Then, you notice the instructions continue on the back of the Recruiting Document. Easter Bunny HQ is actually at the first location you visit twice. + Then, you notice the instructions continue on the back of the Recruiting + Document. Easter Bunny HQ is actually at the first location you visit twice. - For example, if your instructions are R8, R4, R4, R8, the first location you visit twice is 4 blocks away, due East. + For example, if your instructions are R8, R4, R4, R8, the first location you + visit twice is 4 blocks away, due East. How many blocks away is the first location you visit twice? - Your puzzle answer was ___. + Your puzzle answer was 142. If you still want to see it, you can get your puzzle input. diff --git a/2016/day02/problem b/2016/day02/problem index d11017d..90c0fd7 100644 --- a/2016/day02/problem +++ b/2016/day02/problem @@ -2,20 +2,24 @@ Advent of Code --- Day 2: Bathroom Security --- - You arrive at Easter Bunny Headquarters under cover of darkness. However, you left in such a rush that you forgot to - use the bathroom! Fancy office buildings like this one usually have keypad locks on their bathrooms, so you search the - front desk for the code. + You arrive at Easter Bunny Headquarters under cover of darkness. However, + you left in such a rush that you forgot to use the bathroom! Fancy office + buildings like this one usually have keypad locks on their bathrooms, so you + search the front desk for the code. - "In order to improve security," the document you find says, "bathroom codes will no longer be written down. Instead, - please memorize and follow the procedure below to access the bathrooms." + "In order to improve security," the document you find says, "bathroom codes + will no longer be written down. Instead, please memorize and follow the + procedure below to access the bathrooms." - The document goes on to explain that each button to be pressed can be found by starting on the previous button and - moving to adjacent buttons on the keypad: U moves up, D moves down, L moves left, and R moves right. Each line of - instructions corresponds to one button, starting at the previous button (or, for the first line, the "5" button); press - whatever button you're on at the end of each line. If a move doesn't lead to a button, ignore it. + The document goes on to explain that each button to be pressed can be found + by starting on the previous button and moving to adjacent buttons on the + keypad: U moves up, D moves down, L moves left, and R moves right. Each line + of instructions corresponds to one button, starting at the previous button + (or, for the first line, the "5" button); press whatever button you're on at + the end of each line. If a move doesn't lead to a button, ignore it. - You can't hold it much longer, so you decide to figure out the code as you walk to the bathroom. You picture a keypad - like this: + You can't hold it much longer, so you decide to figure out the code as you + walk to the bathroom. You picture a keypad like this: 1 2 3 4 5 6 @@ -28,18 +32,25 @@ Advent of Code LURDL UUUUD - • You start at "5" and move up (to "2"), left (to "1"), and left (you can't, and stay on "1"), so the first button is - 1. - • Starting from the previous button ("1"), you move right twice (to "3") and then down three times (stopping at "9" - after two moves and ignoring the third), ending up with 9. - • Continuing from "9", you move left, up, right, down, and left, ending with 8. - • Finally, you move up four times (stopping at "2"), then down once, ending with 5. + • You start at "5" and move up (to "2"), left (to "1"), and left (you + can't, and stay on "1"), so the first button is 1. + + • Starting from the previous button ("1"), you move right twice (to "3") + and then down three times (stopping at "9" after two moves and ignoring + the third), ending up with 9. + + • Continuing from "9", you move left, up, right, down, and left, ending + with 8. + + • Finally, you move up four times (stopping at "2"), then down once, + ending with 5. So, in this example, the bathroom code is 1985. - Your puzzle input is the instructions from the document you found at the front desk. What is the bathroom code? + Your puzzle input is the instructions from the document you found at the + front desk. What is the bathroom code? - Your puzzle answer was ______. + Your puzzle answer was 98575. --- Part Two --- @@ -66,7 +77,7 @@ Advent of Code Using the same instructions in your puzzle input, what is the correct bathroom code? - Your puzzle answer was _____. + Your puzzle answer was CD8D4. Both parts of this puzzle are complete! They provide two gold stars: ** diff --git a/2016/day03/problem b/2016/day03/problem index 211ecba..af44b84 100644 --- a/2016/day03/problem +++ b/2016/day03/problem @@ -2,32 +2,35 @@ Advent of Code --- Day 3: Squares With Three Sides --- - Now that you can think clearly, you move deeper into the labyrinth of hallways and office - furniture that makes up this part of Easter Bunny HQ. This must be a graphic design - department; the walls are covered in specifications for triangles. + Now that you can think clearly, you move deeper into the labyrinth of + hallways and office furniture that makes up this part of Easter Bunny HQ. + This must be a graphic design department; the walls are covered in + specifications for triangles. Or are they? - The design document gives the side lengths of each triangle it describes, but... 5 10 25? Some - of these aren't triangles. You can't help but mark the impossible ones. + The design document gives the side lengths of each triangle it describes, + but... 5 10 25? Some of these aren't triangles. You can't help but mark the + impossible ones. - In a valid triangle, the sum of any two sides must be larger than the remaining side. For - example, the "triangle" given above is impossible, because 5 + 10 is not larger than 25. + In a valid triangle, the sum of any two sides must be larger than the + remaining side. For example, the "triangle" given above is impossible, + because 5 + 10 is not larger than 25. In your puzzle input, how many of the listed triangles are possible? - Your puzzle answer was ___. + Your puzzle answer was 869. The first half of this puzzle is complete! It provides one gold star: * --- Part Two --- - Now that you've helpfully marked up their design documents, it occurs to you that triangles - are specified in groups of three vertically. Each set of three numbers in a column specifies a - triangle. Rows are unrelated. + Now that you've helpfully marked up their design documents, it occurs to you + that triangles are specified in groups of three vertically. Each set of + three numbers in a column specifies a triangle. Rows are unrelated. - For example, given the following specification, numbers with the same hundreds digit would be - part of the same triangle: + For example, given the following specification, numbers with the same + hundreds digit would be part of the same triangle: 101 301 501 102 302 502 @@ -36,10 +39,10 @@ Advent of Code 202 402 602 203 403 603 - In your puzzle input, and instead reading by columns, how many of the listed triangles are - possible? + In your puzzle input, and instead reading by columns, how many of the listed + triangles are possible? - Although it hasn't changed, you can still get your puzzle input. + Your puzzle answer was 1544 References diff --git a/2016/day04/problem b/2016/day04/problem index 92f197e..dc1b350 100644 --- a/2016/day04/problem +++ b/2016/day04/problem @@ -2,52 +2,59 @@ Advent of Code --- Day 4: Security Through Obscurity --- - Finally, you come across an information kiosk with a list of rooms. Of course, the list is - encrypted and full of decoy data, but the instructions to decode the list are barely hidden - nearby. Better remove the decoy data first. + Finally, you come across an information kiosk with a list of rooms. Of + course, the list is encrypted and full of decoy data, but the instructions + to decode the list are barely hidden nearby. Better remove the decoy data + first. - Each room consists of an encrypted name (lowercase letters separated by dashes) followed by a - dash, a sector ID, and a checksum in square brackets. + Each room consists of an encrypted name (lowercase letters separated by + dashes) followed by a dash, a sector ID, and a checksum in square brackets. - A room is real (not a decoy) if the checksum is the five most common letters in the encrypted - name, in order, with ties broken by alphabetization. For example: + A room is real (not a decoy) if the checksum is the five most common letters + in the encrypted name, in order, with ties broken by alphabetization. For + example: + + • aaaaa-bbb-z-y-x-123[abxyz] is a real room because the most common + letters are a (5), b (3), and then a tie between x, y, and z, which are + listed alphabetically. + + • a-b-c-d-e-f-g-h-987[abcde] is a real room because although the letters + are all tied (1 of each), the first five are listed alphabetically. - • aaaaa-bbb-z-y-x-123[abxyz] is a real room because the most common letters are a (5), b - (3), and then a tie between x, y, and z, which are listed alphabetically. - • a-b-c-d-e-f-g-h-987[abcde] is a real room because although the letters are all tied (1 of - each), the first five are listed alphabetically. • not-a-real-room-404[oarel] is a real room. + • totally-real-room-200[decoy] is not. Of the real rooms from the list above, the sum of their sector IDs is 1514. What is the sum of the sector IDs of the real rooms? - Your puzzle answer was ___________. + Your puzzle answer was 245102. The first half of this puzzle is complete! It provides one gold star: * --- Part Two --- - With all the decoy data out of the way, it's time to decrypt this list and get moving. + With all the decoy data out of the way, it's time to decrypt this list and + get moving. - The room names are encrypted by a state-of-the-art shift cipher, which is nearly unbreakable - without the right software. However, the information kiosk designers at Easter Bunny HQ were - not expecting to deal with a master cryptographer like yourself. + The room names are encrypted by a state-of-the-art shift cipher, which is + nearly unbreakable without the right software. However, the information + kiosk designers at Easter Bunny HQ were not expecting to deal with a master + cryptographer like yourself. - To decrypt a room name, rotate each letter forward through the alphabet a number of times - equal to the room's sector ID. A becomes B, B becomes C, Z becomes A, and so on. Dashes become - spaces. + To decrypt a room name, rotate each letter forward through the alphabet a + number of times equal to the room's sector ID. A becomes B, B becomes C, Z + becomes A, and so on. Dashes become spaces. - For example, the real name for qzmt-zixmtkozy-ivhz-343 is very encrypted name. + For example, the real name for qzmt-zixmtkozy-ivhz-343 is very encrypted + name. What is the sector ID of the room where North Pole objects are stored? Although it hasn't changed, you can still get your puzzle input. - Answer: _____________________ [ [Submit] ] - - You can also [Shareon Twitter Google+ Reddit] this puzzle. + Your puzzle answer was 324. References diff --git a/2016/day05/problem b/2016/day05/problem index f44bb86..4f769e5 100644 --- a/2016/day05/problem +++ b/2016/day05/problem @@ -2,48 +2,72 @@ Advent of Code --- Day 5: How About a Nice Game of Chess? --- - You are faced with a security door designed by Easter Bunny engineers that seem to have acquired most of their security knowledge by watching hacking movies. + You are faced with a security door designed by Easter Bunny engineers that + seem to have acquired most of their security knowledge by watching hacking + movies. - The eight-character password for the door is generated one character at a time by finding the MD5 hash of some Door ID (your puzzle input) and an increasing integer - index (starting with 0). + The eight-character password for the door is generated one character at a + time by finding the MD5 hash of some Door ID (your puzzle input) and an + increasing integer index (starting with 0). - A hash indicates the next character in the password if its hexadecimal representation starts with five zeroes. If it does, the sixth character in the hash is the next - character of the password. + A hash indicates the next character in the password if its hexadecimal + representation starts with five zeroes. If it does, the sixth character in + the hash is the next character of the password. For example, if the Door ID is abc: - • The first index which produces a hash that starts with five zeroes is 3231929, which we find by hashing abc3231929; the sixth character of the hash, and thus the - first character of the password, is 1. - • 5017308 produces the next interesting hash, which starts with 000008f82..., so the second character of the password is 8. - • The third time a hash starts with five zeroes is for abc5278568, discovering the character f. + • The first index which produces a hash that starts with five zeroes is + 3231929, which we find by hashing abc3231929; the sixth character of the + hash, and thus the first character of the password, is 1. - In this example, after continuing this search a total of eight times, the password is 18f47a30. + • 5017308 produces the next interesting hash, which starts with + 000008f82..., so the second character of the password is 8. + + • The third time a hash starts with five zeroes is for abc5278568, + discovering the character f. + + In this example, after continuing this search a total of eight times, the + password is 18f47a30. Given the actual Door ID, what is the password? - Your puzzle answer was ________. + Your puzzle answer was 4543c154. --- Part Two --- - As the door slides open, you are presented with a second door that uses a slightly more inspired security mechanism. Clearly unimpressed by the last version (in what - movie is the password decrypted in order?!), the Easter Bunny engineers have worked out a better solution. + As the door slides open, you are presented with a second door that uses a + slightly more inspired security mechanism. Clearly unimpressed by the last + version (in what movie is the password decrypted in order?!), the Easter + Bunny engineers have worked out a better solution. - Instead of simply filling in the password from left to right, the hash now also indicates the position within the password to fill. You still look for hashes that begin - with five zeroes; however, now, the sixth character represents the position (0-7), and the seventh character is the character to put in that position. + Instead of simply filling in the password from left to right, the hash now + also indicates the position within the password to fill. You still look for + hashes that begin with five zeroes; however, now, the sixth character + represents the position (0-7), and the seventh character is the character to + put in that position. - A hash result of 000001f means that f is the second character in the password. Use only the first result for each position, and ignore invalid positions. + A hash result of 000001f means that f is the second character in the + password. Use only the first result for each position, and ignore invalid + positions. For example, if the Door ID is abc: - • The first interesting hash is from abc3231929, which produces 0000015...; so, 5 goes in position 1: _5______. - • In the previous method, 5017308 produced an interesting hash; however, it is ignored, because it specifies an invalid position (8). - • The second interesting hash is at index 5357525, which produces 000004e...; so, e goes in position 4: _5__e___. + • The first interesting hash is from abc3231929, which produces + 0000015...; so, 5 goes in position 1: _5______. - You almost choke on your popcorn as the final character falls into place, producing the password 05ace8e3. + • In the previous method, 5017308 produced an interesting hash; however, + it is ignored, because it specifies an invalid position (8). - Given the actual Door ID and this new method, what is the password? Be extra proud of your solution if it uses a cinematic "decrypting" animation. + • The second interesting hash is at index 5357525, which produces + 000004e...; so, e goes in position 4: _5__e___. - Your puzzle answer was ________. + You almost choke on your popcorn as the final character falls into place, + producing the password 05ace8e3. + + Given the actual Door ID and this new method, what is the password? Be extra + proud of your solution if it uses a cinematic "decrypting" animation. + + Your puzzle answer was 1050cbbd. Your puzzle input was ojvtpuvg. diff --git a/2016/day06/problem b/2016/day06/problem index c81b579..1cdb87a 100644 --- a/2016/day06/problem +++ b/2016/day06/problem @@ -2,13 +2,16 @@ Advent of Code --- Day 6: Signals and Noise --- - Something is jamming your communications with Santa. Fortunately, your signal is only partially jammed, and protocol in situations like this is to switch to - a simple repetition code to get the message through. + Something is jamming your communications with Santa. Fortunately, your + signal is only partially jammed, and protocol in situations like this is to + switch to a simple repetition code to get the message through. - In this model, the same message is sent repeatedly. You've recorded the repeating message signal (your puzzle input), but the data seems quite corrupted - - almost too badly to recover. Almost. + In this model, the same message is sent repeatedly. You've recorded the + repeating message signal (your puzzle input), but the data seems quite + corrupted - almost too badly to recover. Almost. - All you need to do is figure out which character is most frequent for each position. For example, suppose you had recorded the following messages: + All you need to do is figure out which character is most frequent for each + position. For example, suppose you had recorded the following messages: eedadn drvtee @@ -27,12 +30,14 @@ Advent of Code dvrsen enarar - The most common character in the first column is e; in the second, a; in the third, s, and so on. Combining these characters returns the error-corrected + The most common character in the first column is e; in the second, a; in the + third, s, and so on. Combining these characters returns the error-corrected message, easter. - Given the recording in your puzzle input, what is the error-corrected version of the message being sent? + Given the recording in your puzzle input, what is the error-corrected + version of the message being sent? - Your puzzle answer was ________. + Your puzzle answer was cyxeoccr. --- Part Two --- @@ -47,7 +52,7 @@ Advent of Code Given the recording in your puzzle input and this new decoding methodology, what is the original message that Santa is trying to send? - Your puzzle answer was ________. + Your puzzle answer was batwpask. References diff --git a/2016/day07/problem b/2016/day07/problem index 4c6474a..e098166 100644 --- a/2016/day07/problem +++ b/2016/day07/problem @@ -2,44 +2,62 @@ Advent of Code --- Day 7: Internet Protocol Version 7 --- - While snooping around the local network of EBHQ, you compile a list of IP addresses (they're IPv7, of course; IPv6 is much too limited). - You'd like to figure out which IPs support TLS (transport-layer snooping). + While snooping around the local network of EBHQ, you compile a list of IP + addresses (they're IPv7, of course; IPv6 is much too limited). You'd like to + figure out which IPs support TLS (transport-layer snooping). - An IP supports TLS if it has an Autonomous Bridge Bypass Annotation, or ABBA. An ABBA is any four-character sequence which consists of a - pair of two different characters followed by the reverse of that pair, such as xyyx or abba. However, the IP also must not have an ABBA - within any hypernet sequences, which are contained by square brackets. + An IP supports TLS if it has an Autonomous Bridge Bypass Annotation, or + ABBA. An ABBA is any four-character sequence which consists of a pair of two + different characters followed by the reverse of that pair, such as xyyx or + abba. However, the IP also must not have an ABBA within any hypernet + sequences, which are contained by square brackets. For example: • abba[mnop]qrst supports TLS (abba outside square brackets). - • abcd[bddb]xyyx does not support TLS (bddb is within square brackets, even though xyyx is outside square brackets). - • aaaa[qwer]tyui does not support TLS (aaaa is invalid; the interior characters must be different). - • ioxxoj[asdfgh]zxcvbn supports TLS (oxxo is outside square brackets, even though it's within a larger string). + + • abcd[bddb]xyyx does not support TLS (bddb is within square brackets, + even though xyyx is outside square brackets). + + • aaaa[qwer]tyui does not support TLS (aaaa is invalid; the interior + characters must be different). + + • ioxxoj[asdfgh]zxcvbn supports TLS (oxxo is outside square brackets, even + though it's within a larger string). How many IPs in your puzzle input support TLS? - Your puzzle answer was _____. + Your puzzle answer was 118. --- Part Two --- You would also like to know which IPs support SSL (super-secret listening). - An IP supports SSL if it has an Area-Broadcast Accessor, or ABA, anywhere in the supernet sequences (outside any square bracketed sections), - and a corresponding Byte Allocation Block, or BAB, anywhere in the hypernet sequences. An ABA is any three-character sequence which consists - of the same character twice with a different character between them, such as xyx or aba. A corresponding BAB is the same characters but in - reversed positions: yxy and bab, respectively. + An IP supports SSL if it has an Area-Broadcast Accessor, or ABA, anywhere in + the supernet sequences (outside any square bracketed sections), and a + corresponding Byte Allocation Block, or BAB, anywhere in the hypernet + sequences. An ABA is any three-character sequence which consists of the same + character twice with a different character between them, such as xyx or aba. + A corresponding BAB is the same characters but in reversed positions: yxy + and bab, respectively. For example: - • aba[bab]xyz supports SSL (aba outside square brackets with corresponding bab within square brackets). + • aba[bab]xyz supports SSL (aba outside square brackets with corresponding + bab within square brackets). + • xyx[xyx]xyx does not support SSL (xyx, but no corresponding yxy). - • aaa[kek]eke supports SSL (eke in supernet with corresponding kek in hypernet; the aaa sequence is not related, because the interior - character must be different). - • zazbz[bzb]cdb supports SSL (zaz has no corresponding aza, but zbz has a corresponding bzb, even though zaz and zbz overlap). + + • aaa[kek]eke supports SSL (eke in supernet with corresponding kek in + hypernet; the aaa sequence is not related, because the interior character + must be different). + + • zazbz[bzb]cdb supports SSL (zaz has no corresponding aza, but zbz has a + corresponding bzb, even though zaz and zbz overlap). How many IPs in your puzzle input support SSL? - Your puzzle answer was _______. + Your puzzle answer was 260. References diff --git a/2016/day08/problem b/2016/day08/problem index 675da7f..3452056 100644 --- a/2016/day08/problem +++ b/2016/day08/problem @@ -2,24 +2,33 @@ Advent of Code --- Day 8: Two-Factor Authentication --- - You come across a door implementing what you can only assume is an implementation of two-factor authentication - after a long game of requirements telephone. + You come across a door implementing what you can only assume is an + implementation of two-factor authentication after a long game of + requirements telephone. - To get past the door, you first swipe a keycard (no problem; there was one on a nearby desk). Then, it displays a - code on a little screen, and you type that code on a keypad. Then, presumably, the door unlocks. + To get past the door, you first swipe a keycard (no problem; there was one + on a nearby desk). Then, it displays a code on a little screen, and you type + that code on a keypad. Then, presumably, the door unlocks. - Unfortunately, the screen has been smashed. After a few minutes, you've taken everything apart and figured out how - it works. Now you just have to work out what the screen would have displayed. + Unfortunately, the screen has been smashed. After a few minutes, you've + taken everything apart and figured out how it works. Now you just have to + work out what the screen would have displayed. - The magnetic strip on the card you swiped encodes a series of instructions for the screen; these instructions are - your puzzle input. The screen is 50 pixels wide and 6 pixels tall, all of which start off, and is capable of three - somewhat peculiar operations: + The magnetic strip on the card you swiped encodes a series of instructions + for the screen; these instructions are your puzzle input. The screen is 50 + pixels wide and 6 pixels tall, all of which start off, and is capable of + three somewhat peculiar operations: - • rect AxB turns on all of the pixels in a rectangle at the top-left of the screen which is A wide and B tall. - • rotate row y=A by B shifts all of the pixels in row A (0 is the top row) right by B pixels. Pixels that would - fall off the right end appear at the left end of the row. - • rotate column x=A by B shifts all of the pixels in column A (0 is the left column) down by B pixels. Pixels - that would fall off the bottom appear at the top of the column. + • rect AxB turns on all of the pixels in a rectangle at the top-left of + the screen which is A wide and B tall. + + • rotate row y=A by B shifts all of the pixels in row A (0 is the top row) + right by B pixels. Pixels that would fall off the right end appear at the + left end of the row. + + • rotate column x=A by B shifts all of the pixels in column A (0 is the + left column) down by B pixels. Pixels that would fall off the bottom + appear at the top of the column. For example, here is a simple sequence on a smaller screen: @@ -41,30 +50,31 @@ Advent of Code ###.... .#..... - • rotate column x=1 by 1 again rotates the second column down by one pixel, causing the bottom pixel to wrap back - to the top: + • rotate column x=1 by 1 again rotates the second column down by one + pixel, causing the bottom pixel to wrap back to the top: .#..#.# #.#.... .#..... - As you can see, this display technology is extremely powerful, and will soon dominate the - tiny-code-displaying-screen market. That's what the advertisement on the back of the display tries to convince you, - anyway. + As you can see, this display technology is extremely powerful, and will soon + dominate the tiny-code-displaying-screen market. That's what the + advertisement on the back of the display tries to convince you, anyway. - There seems to be an intermediate check of the voltage used by the display: after you swipe your card, if the - screen did work, how many pixels should be lit? + There seems to be an intermediate check of the voltage used by the display: + after you swipe your card, if the screen did work, how many pixels should be + lit? - Your puzzle answer was _____. + Your puzzle answer was 119. --- Part Two --- - You notice that the screen is only capable of displaying capital letters; in the font it uses, each letter is 5 - pixels wide and 6 tall. + You notice that the screen is only capable of displaying capital letters; in + the font it uses, each letter is 5 pixels wide and 6 tall. After you swipe your card, what code is the screen trying to display? - Your puzzle answer was _____________. + Your puzzle answer was ZFHFSFOGPO. References diff --git a/2016/day09/problem b/2016/day09/problem index 969caad..d6bec0e 100644 --- a/2016/day09/problem +++ b/2016/day09/problem @@ -2,55 +2,83 @@ Advent of Code --- Day 9: Explosives in Cyberspace --- - Wandering around a secure area, you come across a datalink port to a new part of the network. After briefly scanning it for - interesting files, you find one file in particular that catches your attention. It's compressed with an experimental format, but - fortunately, the documentation for the format is nearby. + Wandering around a secure area, you come across a datalink port to a new + part of the network. After briefly scanning it for interesting files, you + find one file in particular that catches your attention. It's compressed + with an experimental format, but fortunately, the documentation for the + format is nearby. - The format compresses a sequence of characters. Whitespace is ignored. To indicate that some sequence should be repeated, a marker is - added to the file, like (10x2). To decompress this marker, take the subsequent 10 characters and repeat them 2 times. Then, continue - reading the file after the repeated data. The marker itself is not included in the decompressed output. + The format compresses a sequence of characters. Whitespace is ignored. To + indicate that some sequence should be repeated, a marker is added to the + file, like (10x2). To decompress this marker, take the subsequent 10 + characters and repeat them 2 times. Then, continue reading the file after + the repeated data. The marker itself is not included in the decompressed + output. - If parentheses or other characters appear within the data referenced by a marker, that's okay - treat it like normal data, not a - marker, and then resume looking for markers after the decompressed section. + If parentheses or other characters appear within the data referenced by a + marker, that's okay - treat it like normal data, not a marker, and then + resume looking for markers after the decompressed section. For example: - • ADVENT contains no markers and decompresses to itself with no changes, resulting in a decompressed length of 6. - • A(1x5)BC repeats only the B a total of 5 times, becoming ABBBBBC for a decompressed length of 7. + • ADVENT contains no markers and decompresses to itself with no changes, + resulting in a decompressed length of 6. + + • A(1x5)BC repeats only the B a total of 5 times, becoming ABBBBBC for a + decompressed length of 7. + • (3x3)XYZ becomes XYZXYZXYZ for a decompressed length of 9. - • A(2x2)BCD(2x2)EFG doubles the BC and EF, becoming ABCBCDEFEFG for a decompressed length of 11. - • (6x1)(1x3)A simply becomes (1x3)A - the (1x3) looks like a marker, but because it's within a data section of another marker, it - is not treated any differently from the A that comes after it. It has a decompressed length of 6. - • X(8x2)(3x3)ABCY becomes X(3x3)ABC(3x3)ABCY (for a decompressed length of 18), because the decompressed data from the (8x2) marker - (the (3x3)ABC) is skipped and not processed further. - What is the decompressed length of the file (your puzzle input)? Don't count whitespace. + • A(2x2)BCD(2x2)EFG doubles the BC and EF, becoming ABCBCDEFEFG for a + decompressed length of 11. - Your puzzle answer was __________. + • (6x1)(1x3)A simply becomes (1x3)A - the (1x3) looks like a marker, but + because it's within a data section of another marker, it is not treated + any differently from the A that comes after it. It has a decompressed + length of 6. + + • X(8x2)(3x3)ABCY becomes X(3x3)ABC(3x3)ABCY (for a decompressed length of + 18), because the decompressed data from the (8x2) marker (the (3x3)ABC) is + skipped and not processed further. + + What is the decompressed length of the file (your puzzle input)? Don't count + whitespace. + + Your puzzle answer was 110346. --- Part Two --- Apparently, the file actually uses version two of the format. - In version two, the only difference is that markers within decompressed data are decompressed. This, the documentation explains, - provides much more substantial compression capabilities, allowing many-gigabyte files to be stored in only a few kilobytes. + In version two, the only difference is that markers within decompressed data + are decompressed. This, the documentation explains, provides much more + substantial compression capabilities, allowing many-gigabyte files to be + stored in only a few kilobytes. For example: - • (3x3)XYZ still becomes XYZXYZXYZ, as the decompressed section contains no markers. - • X(8x2)(3x3)ABCY becomes XABCABCABCABCABCABCY, because the decompressed data from the (8x2) marker is then further decompressed, - thus triggering the (3x3) marker twice for a total of six ABC sequences. - • (27x12)(20x12)(13x14)(7x10)(1x12)A decompresses into a string of A repeated 241920 times. - • (25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN becomes 445 characters long. + • (3x3)XYZ still becomes XYZXYZXYZ, as the decompressed section contains + no markers. - Unfortunately, the computer you brought probably doesn't have enough memory to actually decompress the file; you'll have to come up - with another way to get its decompressed length. + • X(8x2)(3x3)ABCY becomes XABCABCABCABCABCABCY, because the decompressed + data from the (8x2) marker is then further decompressed, thus triggering + the (3x3) marker twice for a total of six ABC sequences. + + • (27x12)(20x12)(13x14)(7x10)(1x12)A decompresses into a string of A + repeated 241920 times. + + • (25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN becomes 445 + characters long. + + Unfortunately, the computer you brought probably doesn't have enough memory + to actually decompress the file; you'll have to come up with another way to + get its decompressed length. What is the decompressed length of the file using this improved format? Although it hasn't changed, you can still get your puzzle input. - Answer: _____________________ [ [Submit] ] + Your puzzle answer was 10774309173. References diff --git a/2016/day10/problem b/2016/day10/problem index 4cc466e..8a1425c 100644 --- a/2016/day10/problem +++ b/2016/day10/problem @@ -2,20 +2,22 @@ Advent of Code --- Day 10: Balance Bots --- - You come upon a factory in which many robots are zooming around handing small microchips to - each other. + You come upon a factory in which many robots are zooming around handing + small microchips to each other. - Upon closer examination, you notice that each bot only proceeds when it has two microchips, - and once it does, it gives each one to a different bot or puts it in a marked "output" bin. - Sometimes, bots take microchips from "input" bins, too. + Upon closer examination, you notice that each bot only proceeds when it has + two microchips, and once it does, it gives each one to a different bot or + puts it in a marked "output" bin. Sometimes, bots take microchips from + "input" bins, too. - Inspecting one of the microchips, it seems like they each contain a single number; the bots - must use some logic to decide what to do with each chip. You access the local control computer - and download the bots' instructions (your puzzle input). + Inspecting one of the microchips, it seems like they each contain a single + number; the bots must use some logic to decide what to do with each chip. + You access the local control computer and download the bots' instructions + (your puzzle input). - Some of the instructions specify that a specific-valued microchip should be given to a - specific bot; the rest of the instructions indicate what a given bot should do with its - lower-value or higher-value chip. + Some of the instructions specify that a specific-valued microchip should be + given to a specific bot; the rest of the instructions indicate what a given + bot should do with its lower-value or higher-value chip. For example, consider the following instructions: @@ -26,29 +28,34 @@ Advent of Code bot 0 gives low to output 2 and high to output 0 value 2 goes to bot 2 - • Initially, bot 1 starts with a value-3 chip, and bot 2 starts with a value-2 chip and a - value-5 chip. - • Because bot 2 has two microchips, it gives its lower one (2) to bot 1 and its higher one - (5) to bot 0. - • Then, bot 1 has two microchips; it puts the value-2 chip in output 1 and gives the value-3 - chip to bot 0. - • Finally, bot 0 has two microchips; it puts the 3 in output 2 and the 5 in output 0. + • Initially, bot 1 starts with a value-3 chip, and bot 2 starts with a + value-2 chip and a value-5 chip. - In the end, output bin 0 contains a value-5 microchip, output bin 1 contains a value-2 - microchip, and output bin 2 contains a value-3 microchip. In this configuration, bot number 2 - is responsible for comparing value-5 microchips with value-2 microchips. + • Because bot 2 has two microchips, it gives its lower one (2) to bot 1 + and its higher one (5) to bot 0. - Based on your instructions, what is the number of the bot that is responsible for comparing - value-61 microchips with value-17 microchips? + • Then, bot 1 has two microchips; it puts the value-2 chip in output 1 and + gives the value-3 chip to bot 0. - Your puzzle answer was ______. + • Finally, bot 0 has two microchips; it puts the 3 in output 2 and the 5 + in output 0. + + In the end, output bin 0 contains a value-5 microchip, output bin 1 contains + a value-2 microchip, and output bin 2 contains a value-3 microchip. In this + configuration, bot number 2 is responsible for comparing value-5 microchips + with value-2 microchips. + + Based on your instructions, what is the number of the bot that is + responsible for comparing value-61 microchips with value-17 microchips? + + Your puzzle answer was 47. --- Part Two --- - What do you get if you multiply together the values of one chip in each of outputs 0, 1, and - 2? + What do you get if you multiply together the values of one chip in each of + outputs 0, 1, and 2? - Your puzzle answer was _______. + Your puzzle answer was 2666. References diff --git a/2016/day11/problem b/2016/day11/problem new file mode 100644 index 0000000..f77d011 --- /dev/null +++ b/2016/day11/problem @@ -0,0 +1,222 @@ +Advent of Code + +--- Day 11: Radioisotope Thermoelectric Generators --- + + You come upon a column of four floors that have been entirely sealed off + from the rest of the building except for a small dedicated lobby. There are + some radiation warnings and a big sign which reads "Radioisotope Testing + Facility". + + According to the project status board, this facility is currently being used + to experiment with Radioisotope Thermoelectric Generators (RTGs, or simply + "generators") that are designed to be paired with specially-constructed + microchips. Basically, an RTG is a highly radioactive rock that generates + electricity through heat. + + The experimental RTGs have poor radiation containment, so they're + dangerously radioactive. The chips are prototypes and don't have normal + radiation shielding, but they do have the ability to generate an + electromagnetic radiation shield when powered. Unfortunately, they can only + be powered by their corresponding RTG. An RTG powering a microchip is still + dangerous to other microchips. + + In other words, if a chip is ever left in the same area as another RTG, and + it's not connected to its own RTG, the chip will be fried. Therefore, it is + assumed that you will follow procedure and keep chips connected to their + corresponding RTG when they're in the same room, and away from other RTGs + otherwise. + + These microchips sound very interesting and useful to your current + activities, and you'd like to try to retrieve them. The fourth floor of the + facility has an assembling machine which can make a self-contained, shielded + computer for you to take with you - that is, if you can bring it all of the + RTGs and microchips. + + Within the radiation-shielded part of the facility (in which it's safe to + have these pre-assembly RTGs), there is an elevator that can move between + the four floors. Its capacity rating means it can carry at most yourself and + two RTGs or microchips in any combination. (They're rigged to some heavy + diagnostic equipment - the assembling machine will detach it for you.) As a + security measure, the elevator will only function if it contains at least + one RTG or microchip. The elevator always stops on each floor to recharge, + and this takes long enough that the items within it and the items on that + floor can irradiate each other. (You can prevent this if a Microchip and its + Generator end up on the same floor in this way, as they can be connected + while the elevator is recharging.) + + You make some notes of the locations of each component of interest (your + puzzle input). Before you don a hazmat suit and start moving things around, + you'd like to have an idea of what you need to do. + + When you enter the containment area, you and the elevator will start on the + first floor. + + For example, suppose the isolated area has the following arrangement: + + The first floor contains a hydrogen-compatible microchip and a + lithium-compatible microchip. + + The second floor contains a hydrogen generator. + + The third floor contains a lithium generator. + + The fourth floor contains nothing relevant. + + As a diagram (F# for a Floor number, E for Elevator, H for Hydrogen, L for + Lithium, M for Microchip, and G for Generator), the initial state looks like + this: + + F4 . . . . . + F3 . . . LG . + F2 . HG . . . + F1 E . HM . LM + + Then, to get everything up to the assembling machine on the fourth floor, + the following steps could be taken: + + • Bring the Hydrogen-compatible Microchip to the second floor, which is + safe because it can get power from the Hydrogen Generator: + + F4 . . . . . + F3 . . . LG . + F2 E HG HM . . + F1 . . . . LM + + • Bring both Hydrogen-related items to the third floor, which is safe + because the Hydrogen-compatible microchip is getting power from its + generator: + + F4 . . . . . + F3 E HG HM LG . + F2 . . . . . + F1 . . . . LM + + • Leave the Hydrogen Generator on floor three, but bring the + Hydrogen-compatible Microchip back down with you so you can still use the + elevator: + + F4 . . . . . + F3 . HG . LG . + F2 E . HM . . + F1 . . . . LM + + • At the first floor, grab the Lithium-compatible Microchip, which is safe + because Microchips don't affect each other: + + F4 . . . . . + F3 . HG . LG . + F2 . . . . . + F1 E . HM . LM + + • Bring both Microchips up one floor, where there is nothing to fry them: + + F4 . . . . . + F3 . HG . LG . + F2 E . HM . LM + F1 . . . . . + + • Bring both Microchips up again to floor three, where they can be + temporarily connected to their corresponding generators while the elevator + recharges, preventing either of them from being fried: + + F4 . . . . . + F3 E HG HM LG LM + F2 . . . . . + F1 . . . . . + + • Bring both Microchips to the fourth floor: + + F4 E . HM . LM + F3 . HG . LG . + F2 . . . . . + F1 . . . . . + + • Leave the Lithium-compatible microchip on the fourth floor, but bring + the Hydrogen-compatible one so you can still use the elevator; this is + safe because although the Lithium Generator is on the destination floor, + you can connect Hydrogen-compatible microchip to the Hydrogen Generator + there: + + F4 . . . . LM + F3 E HG HM LG . + F2 . . . . . + F1 . . . . . + + • Bring both Generators up to the fourth floor, which is safe because you + can connect the Lithium-compatible Microchip to the Lithium Generator upon + arrival: + + F4 E HG . LG LM + F3 . . HM . . + F2 . . . . . + F1 . . . . . + + • Bring the Lithium Microchip with you to the third floor so you can use + the elevator: + + F4 . HG . LG . + F3 E . HM . LM + F2 . . . . . + F1 . . . . . + + • Bring both Microchips to the fourth floor: + + F4 E HG HM LG LM + F3 . . . . . + F2 . . . . . + F1 . . . . . + + In this arrangement, it takes 11 steps to collect all of the objects at the + fourth floor for assembly. (Each elevator stop counts as one step, even if + nothing is added to or removed from it.) + + In your situation, what is the minimum number of steps required to bring all + of the objects to the fourth floor? + + Your puzzle answer was 31. + +--- Part Two --- + + You step into the cleanroom separating the lobby from the isolated area and + put on the hazmat suit. + + Upon entering the isolated containment area, however, you notice some extra + parts on the first floor that weren't listed on the record outside: + + • An elerium generator. + • An elerium-compatible microchip. + • A dilithium generator. + • A dilithium-compatible microchip. + + These work just like the other generators and microchips. You'll have to get + them up to assembly as well. + + What is the minimum number of steps required to bring all of the objects, + including these four new ones, to the fourth floor? + + Your puzzle answer was 55. + + 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 + . http://adventofcode.com/ + . http://adventofcode.com/2016/about + . http://adventofcode.com/2016/support + . http://adventofcode.com/2016/events + . http://adventofcode.com/2016/settings + . http://adventofcode.com/2016/auth/logout + . http://adventofcode.com/2016 + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/leaderboard + . http://adventofcode.com/2016/stats + . http://adventofcode.com/2016/sponsors + . http://adventofcode.com/2016/sponsors + . https://en.wikipedia.org/wiki/Radioisotope_thermoelectric_generator + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/day/11/input diff --git a/2016/day12/problem b/2016/day12/problem index 7c4c69b..80033e0 100644 --- a/2016/day12/problem +++ b/2016/day12/problem @@ -2,31 +2,40 @@ Advent of Code --- Day 12: Leonardo's Monorail --- - You finally reach the top floor of this building: a garden with a slanted glass ceiling. Looks like there are no more - stars to be had. + You finally reach the top floor of this building: a garden with a slanted + glass ceiling. Looks like there are no more stars to be had. - While sitting on a nearby bench amidst some tiger lilies, you manage to decrypt some of the files you extracted from - the servers downstairs. + While sitting on a nearby bench amidst some tiger lilies, you manage to + decrypt some of the files you extracted from the servers downstairs. - According to these documents, Easter Bunny HQ isn't just this building - it's a collection of buildings in the nearby - area. They're all connected by a local monorail, and there's another building not far from here! Unfortunately, being - night, the monorail is currently not operating. + According to these documents, Easter Bunny HQ isn't just this building - + it's a collection of buildings in the nearby area. They're all connected by + a local monorail, and there's another building not far from here! + Unfortunately, being night, the monorail is currently not operating. - You remotely connect to the monorail control systems and discover that the boot sequence expects a password. The - password-checking logic (your puzzle input) is easy to extract, but the code it uses is strange: it's assembunny code - designed for the new computer you just assembled. You'll have to execute the code and get the password. + You remotely connect to the monorail control systems and discover that the + boot sequence expects a password. The password-checking logic (your puzzle + input) is easy to extract, but the code it uses is strange: it's assembunny + code designed for the new computer you just assembled. You'll have to + execute the code and get the password. - The assembunny code you've extracted operates on four registers (a, b, c, and d) that start at 0 and can hold any - integer. However, it seems to make use of only a few instructions: + The assembunny code you've extracted operates on four registers (a, b, c, + and d) that start at 0 and can hold any integer. However, it seems to make + use of only a few instructions: + + • cpy x y copies x (either an integer or the value of a register) into + register y. - • cpy x y copies x (either an integer or the value of a register) into register y. • inc x increases the value of register x by one. - • dec x decreases the value of register x by one. - • jnz x y jumps to an instruction y away (positive means forward; negative means backward), but only if x is not - zero. - The jnz instruction moves relative to itself: an offset of -1 would continue at the previous instruction, while an - offset of 2 would skip over the next instruction. + • dec x decreases the value of register x by one. + + • jnz x y jumps to an instruction y away (positive means forward; negative + means backward), but only if x is not zero. + + The jnz instruction moves relative to itself: an offset of -1 would continue + at the previous instruction, while an offset of 2 would skip over the next + instruction. For example: @@ -37,22 +46,26 @@ Advent of Code jnz a 2 dec a - The above code would set register a to 41, increase its value by 2, decrease its value by 1, and then skip the last - dec a (because a is not zero, so the jnz a 2 skips it), leaving register a at 42. When you move past the last + The above code would set register a to 41, increase its value by 2, decrease + its value by 1, and then skip the last dec a (because a is not zero, so the + jnz a 2 skips it), leaving register a at 42. When you move past the last instruction, the program halts. - After executing the assembunny code in your puzzle input, what value is left in register a? + After executing the assembunny code in your puzzle input, what value is left + in register a? - Your puzzle answer was __________. + Your puzzle answer was 318077. --- Part Two --- - As you head down the fire escape to the monorail, you notice it didn't start; register c needs to be initialized to - the position of the ignition key. + As you head down the fire escape to the monorail, you notice it didn't + start; register c needs to be initialized to the position of the ignition + key. - If you instead initialize register c to be 1, what value is now left in register a? + If you instead initialize register c to be 1, what value is now left in + register a? - Your puzzle answer was ___________. + Your puzzle answer was 9227731. References diff --git a/2016/day13/problem b/2016/day13/problem index 2767b1b..5f51a39 100644 --- a/2016/day13/problem +++ b/2016/day13/problem @@ -2,25 +2,33 @@ Advent of Code --- Day 13: A Maze of Twisty Little Cubicles --- - You arrive at the first floor of this new building to discover a much less welcoming environment than the shiny atrium of the - last one. Instead, you are in a maze of twisty little cubicles, all alike. + You arrive at the first floor of this new building to discover a much less + welcoming environment than the shiny atrium of the last one. Instead, you + are in a maze of twisty little cubicles, all alike. - Every location in this area is addressed by a pair of non-negative integers (x,y). Each such coordinate is either a wall or an - open space. You can't move diagonally. The cube maze starts at 0,0 and seems to extend infinitely toward positive x and y; - negative values are invalid, as they represent a location outside the building. You are in a small waiting area at 1,1. + Every location in this area is addressed by a pair of non-negative integers + (x,y). Each such coordinate is either a wall or an open space. You can't + move diagonally. The cube maze starts at 0,0 and seems to extend infinitely + toward positive x and y; negative values are invalid, as they represent a + location outside the building. You are in a small waiting area at 1,1. - While it seems chaotic, a nearby morale-boosting poster explains, the layout is actually quite logical. You can determine - whether a given x,y coordinate will be a wall or an open space using a simple system: + While it seems chaotic, a nearby morale-boosting poster explains, the layout + is actually quite logical. You can determine whether a given x,y coordinate + will be a wall or an open space using a simple system: • Find x*x + 3*x + 2*x*y + y + y*y. + • Add the office designer's favorite number (your puzzle input). - • Find the binary representation of that sum; count the number of bits that are 1. + + • Find the binary representation of that sum; count the number of bits + that are 1. • If the number of bits that are 1 is even, it's an open space. • If the number of bits that are 1 is odd, it's a wall. - For example, if the office designer's favorite number were 10, drawing walls as # and open spaces as ., the corner of the - building containing 0,0 would look like this: + For example, if the office designer's favorite number were 10, drawing walls + as # and open spaces as ., the corner of the building containing 0,0 would + look like this: 0123456789 0 .#.####.## @@ -31,7 +39,8 @@ Advent of Code 5 ..##....#. 6 #...##.### - Now, suppose you wanted to reach 7,4. The shortest route you could take is marked as O: + Now, suppose you wanted to reach 7,4. The shortest route you could take is + marked as O: 0123456789 0 .#.####.## @@ -42,21 +51,23 @@ Advent of Code 5 ..##OOO.#. 6 #...##.### - Thus, reaching 7,4 would take a minimum of 11 steps (starting from your current location, 1,1). + Thus, reaching 7,4 would take a minimum of 11 steps (starting from your + current location, 1,1). What is the fewest number of steps required for you to reach 31,39? - Your puzzle answer was _____. + Your puzzle answer was 86. The first half of this puzzle is complete! It provides one gold star: * --- Part Two --- - How many locations (distinct x,y coordinates, including your starting location) can you reach in at most 50 steps? + How many locations (distinct x,y coordinates, including your starting + location) can you reach in at most 50 steps? Your puzzle input is still 1364. - Answer: _____________________ + Answer: 127 References diff --git a/2016/day14/problem b/2016/day14/problem index 5bccbba..db14e67 100644 --- a/2016/day14/problem +++ b/2016/day14/problem @@ -2,45 +2,67 @@ Advent of Code --- Day 14: One-Time Pad --- - In order to communicate securely with Santa while you're on this mission, you've been using a one-time pad that you generate using a pre-agreed algorithm. - Unfortunately, you've run out of keys in your one-time pad, and so you need to generate some more. + In order to communicate securely with Santa while you're on this mission, + you've been using a one-time pad that you generate using a pre-agreed + algorithm. Unfortunately, you've run out of keys in your one-time pad, and + so you need to generate some more. - To generate keys, you first get a stream of random data by taking the MD5 of a pre-arranged salt (your puzzle input) and an increasing integer index (starting with 0, - and represented in decimal); the resulting MD5 hash should be represented as a string of lowercase hexadecimal digits. + To generate keys, you first get a stream of random data by taking the MD5 of + a pre-arranged salt (your puzzle input) and an increasing integer index + (starting with 0, and represented in decimal); the resulting MD5 hash should + be represented as a string of lowercase hexadecimal digits. - However, not all of these MD5 hashes are keys, and you need 64 new keys for your one-time pad. A hash is a key only if: + However, not all of these MD5 hashes are keys, and you need 64 new keys for + your one-time pad. A hash is a key only if: - • It contains three of the same character in a row, like 777. Only consider the first such triplet in a hash. - • One of the next 1000 hashes in the stream contains that same character five times in a row, like 77777. + • It contains three of the same character in a row, like 777. Only + consider the first such triplet in a hash. - Considering future hashes for five-of-a-kind sequences does not cause those hashes to be skipped; instead, regardless of whether the current hash is a key, always - resume testing for keys starting with the very next hash. + • One of the next 1000 hashes in the stream contains that same character + five times in a row, like 77777. + + Considering future hashes for five-of-a-kind sequences does not cause those + hashes to be skipped; instead, regardless of whether the current hash is a + key, always resume testing for keys starting with the very next hash. For example, if the pre-arranged salt is abc: - • The first index which produces a triple is 18, because the MD5 hash of abc18 contains ...cc38887a5.... However, index 18 does not count as a key for your one-time - pad, because none of the next thousand hashes (index 19 through index 1018) contain 88888. - • The next index which produces a triple is 39; the hash of abc39 contains eee. It is also the first key: one of the next thousand hashes (the one at index 816) - contains eeeee. - • None of the next six triples are keys, but the one after that, at index 92, is: it contains 999 and index 200 contains 99999. - • Eventually, index 22728 meets all of the criteria to generate the 64th key. + • The first index which produces a triple is 18, because the MD5 hash of + abc18 contains ...cc38887a5.... However, index 18 does not count as a key + for your one-time pad, because none of the next thousand hashes (index 19 + through index 1018) contain 88888. + + • The next index which produces a triple is 39; the hash of abc39 contains + eee. It is also the first key: one of the next thousand hashes (the one at + index 816) contains eeeee. + + • None of the next six triples are keys, but the one after that, at index + 92, is: it contains 999 and index 200 contains 99999. + + • Eventually, index 22728 meets all of the criteria to generate the 64th + key. So, using our example salt of abc, index 22728 produces the 64th key. - Given the actual salt in your puzzle input, what index produces your 64th one-time pad key? + Given the actual salt in your puzzle input, what index produces your 64th + one-time pad key? Your puzzle input was cuanljph. - Your puzzle answer was ________. + Your puzzle answer was 23769. --- Part Two --- - Of course, in order to make this process even more secure, you've also implemented key stretching. + Of course, in order to make this process even more secure, you've also + implemented key stretching. - Key stretching forces attackers to spend more time generating hashes. Unfortunately, it forces everyone else to spend more time, too. + Key stretching forces attackers to spend more time generating hashes. + Unfortunately, it forces everyone else to spend more time, too. - To implement key stretching, whenever you generate a hash, before you use it, you first find the MD5 hash of that hash, then the MD5 hash of that hash, and so on, a - total of 2016 additional hashings. Always use lowercase hexadecimal representations of hashes. + To implement key stretching, whenever you generate a hash, before you use + it, you first find the MD5 hash of that hash, then the MD5 hash of that + hash, and so on, a total of 2016 additional hashings. Always use lowercase + hexadecimal representations of hashes. For example, to find the stretched hash for index 0 and salt abc: @@ -50,18 +72,26 @@ Advent of Code • ...repeat many times... • Then, find the MD5 hash of that hash: a107ff634856bb300138cac6568c0f24. - So, the stretched hash for index 0 in this situation is a107ff.... In the end, you find the original hash (one use of MD5), then find the hash-of-the-previous-hash 2016 - times, for a total of 2017 uses of MD5. + So, the stretched hash for index 0 in this situation is a107ff.... In the + end, you find the original hash (one use of MD5), then find the + hash-of-the-previous-hash 2016 times, for a total of 2017 uses of MD5. - The rest of the process remains the same, but now the keys are entirely different. Again for salt abc: + The rest of the process remains the same, but now the keys are entirely + different. Again for salt abc: - • The first triple (222, at index 5) has no matching 22222 in the next thousand hashes. - • The second triple (eee, at index 10) hash a matching eeeee at index 89, and so it is the first key. - • Eventually, index 22551 produces the 64th key (triple fff with matching fffff at index 22859. + • The first triple (222, at index 5) has no matching 22222 in the next + thousand hashes. - Given the actual salt in your puzzle input and using 2016 extra MD5 calls of key stretching, what index now produces your 64th one-time pad key? + • The second triple (eee, at index 10) hash a matching eeeee at index 89, + and so it is the first key. - Your puzzle answer was ________. + • Eventually, index 22551 produces the 64th key (triple fff with matching + fffff at index 22859. + + Given the actual salt in your puzzle input and using 2016 extra MD5 calls of + key stretching, what index now produces your 64th one-time pad key? + + Your puzzle answer was 20606. Your puzzle input was cuanljph. diff --git a/2016/day15/problem b/2016/day15/problem index 7e83816..a334840 100644 --- a/2016/day15/problem +++ b/2016/day15/problem @@ -2,49 +2,76 @@ Advent of Code --- Day 15: Timing is Everything --- - The halls open into an interior plaza containing a large kinetic sculpture. The sculpture is in a sealed enclosure and seems to involve a set of identical spherical capsules that are carried to the top and allowed to bounce through - the maze of spinning pieces. + The halls open into an interior plaza containing a large kinetic sculpture. + The sculpture is in a sealed enclosure and seems to involve a set of + identical spherical capsules that are carried to the top and allowed to + bounce through the maze of spinning pieces. - Part of the sculpture is even interactive! When a button is pressed, a capsule is dropped and tries to fall through slots in a set of rotating discs to finally go through a little hole at the bottom and come out of the sculpture. If - any of the slots aren't aligned with the capsule as it passes, the capsule bounces off the disc and soars away. You feel compelled to get one of those capsules. + Part of the sculpture is even interactive! When a button is pressed, a + capsule is dropped and tries to fall through slots in a set of rotating + discs to finally go through a little hole at the bottom and come out of the + sculpture. If any of the slots aren't aligned with the capsule as it passes, + the capsule bounces off the disc and soars away. You feel compelled to get + one of those capsules. - The discs pause their motion each second and come in different sizes; they seem to each have a fixed number of positions at which they stop. You decide to call the position with the slot 0, and count up for each position it reaches - next. + The discs pause their motion each second and come in different sizes; they + seem to each have a fixed number of positions at which they stop. You decide + to call the position with the slot 0, and count up for each position it + reaches next. - Furthermore, the discs are spaced out so that after you push the button, one second elapses before the first disc is reached, and one second elapses as the capsule passes from one disk to the one below it. So, if you push the button - at time=100, then the capsule reaches the top disc at time=101, the second disc at time=102, the third disc at time=103, and so on. + Furthermore, the discs are spaced out so that after you push the button, one + second elapses before the first disc is reached, and one second elapses as + the capsule passes from one disk to the one below it. So, if you push the + button at time=100, then the capsule reaches the top disc at time=101, the + second disc at time=102, the third disc at time=103, and so on. - The button will only drop a capsule at an integer time - no fractional seconds allowed. + The button will only drop a capsule at an integer time - no fractional + seconds allowed. For example, at time=0, suppose you see the following arrangement: Disc #1 has 5 positions; at time=0, it is at position 4. Disc #2 has 2 positions; at time=0, it is at position 1. - If you press the button exactly at time=0, the capsule would start to fall; it would reach the first disc at time=1. Since the first disc was at position 4 at time=0, by time=1 it has ticked one position forward. As a five-position - disc, the next position is 0, and the capsule falls through the slot. + If you press the button exactly at time=0, the capsule would start to fall; + it would reach the first disc at time=1. Since the first disc was at + position 4 at time=0, by time=1 it has ticked one position forward. As a + five-position disc, the next position is 0, and the capsule falls through + the slot. - Then, at time=2, the capsule reaches the second disc. The second disc has ticked forward two positions at this point: it started at position 1, then continued to position 0, and finally ended up at position 1 again. Because there's - only a slot at position 0, the capsule bounces away. + Then, at time=2, the capsule reaches the second disc. The second disc has + ticked forward two positions at this point: it started at position 1, then + continued to position 0, and finally ended up at position 1 again. Because + there's only a slot at position 0, the capsule bounces away. - If, however, you wait until time=5 to push the button, then when the capsule reaches each disc, the first disc will have ticked forward 5+1 = 6 times (to position 0), and the second disc will have ticked forward 5+2 = 7 times (also - to position 0). In this case, the capsule would fall through the discs and come out of the machine. + If, however, you wait until time=5 to push the button, then when the capsule + reaches each disc, the first disc will have ticked forward 5+1 = 6 times (to + position 0), and the second disc will have ticked forward 5+2 = 7 times + (also to position 0). In this case, the capsule would fall through the discs + and come out of the machine. - However, your situation has more than two discs; you've noted their positions in your puzzle input. What is the first time you can press the button to get a capsule? + However, your situation has more than two discs; you've noted their + positions in your puzzle input. What is the first time you can press the + button to get a capsule? - Your puzzle answer was _________. + Your puzzle answer was 400589. --- Part Two --- - After getting the first capsule (it contained a star! what great fortune!), the machine detects your success and begins to rearrange itself. + After getting the first capsule (it contained a star! what great fortune!), + the machine detects your success and begins to rearrange itself. - When it's done, the discs are back in their original configuration as if it were time=0 again, but a new disc with 11 positions and starting at position 0 has appeared exactly one second below the previously-bottom disc. + When it's done, the discs are back in their original configuration as if it + were time=0 again, but a new disc with 11 positions and starting at position + 0 has appeared exactly one second below the previously-bottom disc. - With this new disc, and counting again starting from time=0 with the configuration in your puzzle input, what is the first time you can press the button to get another capsule? + With this new disc, and counting again starting from time=0 with the + configuration in your puzzle input, what is the first time you can press the + button to get another capsule? Although it hasn't changed, you can still get your puzzle input. - Answer: _____________________ + Answer: 3045959 References diff --git a/2016/day16/problem b/2016/day16/problem index 34bb09a..716e9e3 100644 --- a/2016/day16/problem +++ b/2016/day16/problem @@ -2,20 +2,27 @@ Advent of Code --- Day 16: Dragon Checksum --- - You're done scanning this part of the network, but you've left traces of your presence. You need to - overwrite some disks with random-looking data to cover your tracks and update the local security system - with a new checksum for those disks. + You're done scanning this part of the network, but you've left traces of + your presence. You need to overwrite some disks with random-looking data to + cover your tracks and update the local security system with a new checksum + for those disks. - For the data to not be suspiscious, it needs to have certain properties; purely random data will be - detected as tampering. To generate appropriate random data, you'll need to use a modified dragon curve. + For the data to not be suspiscious, it needs to have certain properties; + purely random data will be detected as tampering. To generate appropriate + random data, you'll need to use a modified dragon curve. - Start with an appropriate initial state (your puzzle input). Then, so long as you don't have enough data - yet to fill the disk, repeat the following steps: + Start with an appropriate initial state (your puzzle input). Then, so long + as you don't have enough data yet to fill the disk, repeat the following + steps: • Call the data you have at this point "a". + • Make a copy of "a"; call this copy "b". + • Reverse the order of the characters in "b". + • In "b", replace all instances of 0 with 1 and all 1s with 0. + • The resulting data is "a", then a single 0, then "b". For example, after a single step of this process, @@ -27,44 +34,62 @@ Advent of Code Repeat these steps until you have enough data to fill the desired disk. - Once the data has been generated, you also need to create a checksum of that data. Calculate the checksum - only for the data that fits on the disk, even if you generated more data than that in the previous step. + Once the data has been generated, you also need to create a checksum of that + data. Calculate the checksum only for the data that fits on the disk, even + if you generated more data than that in the previous step. - The checksum for some given data is created by considering each non-overlapping pair of characters in the - input data. If the two characters match (00 or 11), the next checksum character is a 1. If the characters - do not match (01 or 10), the next checksum character is a 0. This should produce a new string which is - exactly half as long as the original. If the length of the checksum is even, repeat the process until you - end up with a checksum with an odd length. + The checksum for some given data is created by considering each + non-overlapping pair of characters in the input data. If the two characters + match (00 or 11), the next checksum character is a 1. If the characters do + not match (01 or 10), the next checksum character is a 0. This should + produce a new string which is exactly half as long as the original. If the + length of the checksum is even, repeat the process until you end up with a + checksum with an odd length. - For example, suppose we want to fill a disk of length 12, and when we finally generate a string of at - least length 12, the first 12 characters are 110010110100. To generate its checksum: + For example, suppose we want to fill a disk of length 12, and when we + finally generate a string of at least length 12, the first 12 characters are + 110010110100. To generate its checksum: • Consider each pair: 11, 00, 10, 11, 01, 00. + • These are same, same, different, same, different, same, producing 110101. - • The resulting string has length 6, which is even, so we repeat the process. + + • The resulting string has length 6, which is even, so we repeat the + process. + • The pairs are 11 (same), 01 (different), 01 (different). + • This produces the checksum 100, which has an odd length, so we stop. Therefore, the checksum for 110010110100 is 100. - Combining all of these steps together, suppose you want to fill a disk of length 20 using an initial state - of 10000: + Combining all of these steps together, suppose you want to fill a disk of + length 20 using an initial state of 10000: - • Because 10000 is too short, we first use the modified dragon curve to make it longer. - • After one round, it becomes 10000011110 (11 characters), still too short. - • After two rounds, it becomes 10000011110010000111110 (23 characters), which is enough. - • Since we only need 20, but we have 23, we get rid of all but the first 20 characters: - 10000011110010000111. - • Next, we start calculating the checksum; after one round, we have 0111110101, which 10 characters long - (even), so we continue. - • After two rounds, we have 01100, which is 5 characters long (odd), so we are done. + • Because 10000 is too short, we first use the modified dragon curve to + make it longer. + + • After one round, it becomes 10000011110 (11 characters), still too + short. + + • After two rounds, it becomes 10000011110010000111110 (23 characters), + which is enough. + + • Since we only need 20, but we have 23, we get rid of all but the first + 20 characters: 10000011110010000111. + + • Next, we start calculating the checksum; after one round, we have + 0111110101, which 10 characters long (even), so we continue. + + • After two rounds, we have 01100, which is 5 characters long (odd), so we + are done. In this example, the correct checksum would therefore be 01100. - The first disk you have to fill has length 272. Using the initial state in your puzzle input, what is the - correct checksum? + The first disk you have to fill has length 272. Using the initial state in + your puzzle input, what is the correct checksum? - Your puzzle answer _____________________. + Your puzzle answer 10011010010010010. The first half of this puzzle is complete! It provides one gold star: * @@ -75,7 +100,7 @@ Advent of Code Your puzzle input is still 00111101111101000. - Answer: _____________________ + Answer: 10101011110100011. References diff --git a/2016/day17/problem b/2016/day17/problem index 34c43f1..5fd8d95 100644 --- a/2016/day17/problem +++ b/2016/day17/problem @@ -2,9 +2,9 @@ Advent of Code --- Day 17: Two Steps Forward --- - You're trying to access a secure vault protected by a 4x4 grid of small rooms connected by - doors. You start in the top-left room (marked S), and you can access the vault (marked V) once - you reach the bottom-right room: + You're trying to access a secure vault protected by a 4x4 grid of small + rooms connected by doors. You start in the top-left room (marked S), and you + can access the vault (marked V) once you reach the bottom-right room: ######### #S| | | # @@ -18,52 +18,56 @@ Advent of Code Fixed walls are marked with #, and doors are marked with - or |. - The doors in your current room are either open or closed (and locked) based on the hexadecimal - MD5 hash of a passcode (your puzzle input) followed by a sequence of uppercase characters - representing the path you have taken so far (U for up, D for down, L for left, and R for - right). + The doors in your current room are either open or closed (and locked) based + on the hexadecimal MD5 hash of a passcode (your puzzle input) followed by a + sequence of uppercase characters representing the path you have taken so far + (U for up, D for down, L for left, and R for right). - Only the first four characters of the hash are used; they represent, respectively, the doors - up, down, left, and right from your current position. Any b, c, d, e, or f means that the - corresponding door is open; any other character (any number or a) means that the corresponding - door is closed and locked. + Only the first four characters of the hash are used; they represent, + respectively, the doors up, down, left, and right from your current + position. Any b, c, d, e, or f means that the corresponding door is open; + any other character (any number or a) means that the corresponding door is + closed and locked. - To access the vault, all you need to do is reach the bottom-right room; reaching this room - opens the vault and all doors in the maze. + To access the vault, all you need to do is reach the bottom-right room; + reaching this room opens the vault and all doors in the maze. - For example, suppose the passcode is hijkl. Initially, you have taken no steps, and so your - path is empty: you simply find the MD5 hash of hijkl alone. The first four characters of this - hash are ced9, which indicate that up is open (c), down is open (e), left is open (d), and - right is closed and locked (9). Because you start in the top-left corner, there are no "up" or + For example, suppose the passcode is hijkl. Initially, you have taken no + steps, and so your path is empty: you simply find the MD5 hash of hijkl + alone. The first four characters of this hash are ced9, which indicate that + up is open (c), down is open (e), left is open (d), and right is closed and + locked (9). Because you start in the top-left corner, there are no "up" or "left" doors to be open, so your only choice is down. - Next, having gone only one step (down, or D), you find the hash of hijklD. This produces f2bc, - which indicates that you can go back up, left (but that's a wall), or right. Going right means - hashing hijklDR to get 5745 - all doors closed and locked. However, going up instead is - worthwhile: even though it returns you to the room you started in, your path would then be DU, - opening a different set of doors. + Next, having gone only one step (down, or D), you find the hash of hijklD. + This produces f2bc, which indicates that you can go back up, left (but + that's a wall), or right. Going right means hashing hijklDR to get 5745 - + all doors closed and locked. However, going up instead is worthwhile: even + though it returns you to the room you started in, your path would then be + DU, opening a different set of doors. - After going DU (and then hashing hijklDU to get 528e), only the right door is open; after - going DUR, all doors lock. (Fortunately, your actual passcode is not hijkl). + After going DU (and then hashing hijklDU to get 528e), only the right door + is open; after going DUR, all doors lock. (Fortunately, your actual passcode + is not hijkl). - Passcodes actually used by Easter Bunny Vault Security do allow access to the vault if you - know the right path. For example: + Passcodes actually used by Easter Bunny Vault Security do allow access to + the vault if you know the right path. For example: • If your passcode were ihgpwlah, the shortest path would be DDRRRD. • With kglvqrro, the shortest path would be DDUDRLRRUDRD. • With ulqzkmiv, the shortest would be DRURDRUDDLLDLUURRDULRLDUUDDDRR. - Given your vault's passcode, what is the shortest path (the actual path, not just the length) - to reach the vault? + Given your vault's passcode, what is the shortest path (the actual path, not + just the length) to reach the vault? - Your puzzle answer was __________________. + Your puzzle answer was DRRDRLDURD. --- Part Two --- - You're curious how robust this security solution really is, and so you decide to find longer - and longer paths which still provide access to the vault. You remember that paths always end - the first time they reach the bottom-right room (that is, they can never pass through it, only - end in it). + You're curious how robust this security solution really is, and so you + decide to find longer and longer paths which still provide access to the + vault. You remember that paths always end the first time they reach the + bottom-right room (that is, they can never pass through it, only end in it). For example: @@ -73,7 +77,7 @@ Advent of Code What is the length of the longest path that reaches the vault? - Your puzzle answer was _______. + Your puzzle answer was 618. References diff --git a/2016/day18/problem b/2016/day18/problem index 7b26fbe..a6e231e 100644 --- a/2016/day18/problem +++ b/2016/day18/problem @@ -2,28 +2,32 @@ Advent of Code --- Day 18: Like a Rogue --- - As you enter this room, you hear a loud click! Some of the tiles in the floor here seem to be - pressure plates for traps, and the trap you just triggered has run out of... whatever it tried - to do to you. You doubt you'll be so lucky next time. + As you enter this room, you hear a loud click! Some of the tiles in the + floor here seem to be pressure plates for traps, and the trap you just + triggered has run out of... whatever it tried to do to you. You doubt you'll + be so lucky next time. - Upon closer examination, the traps and safe tiles in this room seem to follow a pattern. The - tiles are arranged into rows that are all the same width; you take note of the safe tiles (.) - and traps (^) in the first row (your puzzle input). + Upon closer examination, the traps and safe tiles in this room seem to + follow a pattern. The tiles are arranged into rows that are all the same + width; you take note of the safe tiles (.) and traps (^) in the first row + (your puzzle input). - The type of tile (trapped or safe) in each row is based on the types of the tiles in the same - position, and to either side of that position, in the previous row. (If either side is off - either end of the row, it counts as "safe" because there isn't a trap embedded in the wall.) + The type of tile (trapped or safe) in each row is based on the types of the + tiles in the same position, and to either side of that position, in the + previous row. (If either side is off either end of the row, it counts as + "safe" because there isn't a trap embedded in the wall.) - For example, suppose you know the first row (with tiles marked by letters) and want to - determine the next row (with tiles marked by numbers): + For example, suppose you know the first row (with tiles marked by letters) + and want to determine the next row (with tiles marked by numbers): ABCDE 12345 - The type of tile 2 is based on the types of tiles A, B, and C; the type of tile 5 is based on - tiles D, E, and an imaginary "safe" tile. Let's call these three tiles from the previous row - the left, center, and right tiles, respectively. Then, a new tile is a trap only in one of the - following situations: + The type of tile 2 is based on the types of tiles A, B, and C; the type of + tile 5 is based on tiles D, E, and an imaginary "safe" tile. Let's call + these three tiles from the previous row the left, center, and right tiles, + respectively. Then, a new tile is a trap only in one of the following + situations: • Its left and center tiles are traps, but its right tile is not. • Its center and right tiles are traps, but its left tile is not. @@ -32,24 +36,30 @@ Advent of Code In any other situation, the new tile is safe. - Then, starting with the row ..^^., you can determine the next row by applying those rules to - each new tile: + Then, starting with the row ..^^., you can determine the next row by + applying those rules to each new tile: - • The leftmost character on the next row considers the left (nonexistent, so we assume - "safe"), center (the first ., which means "safe"), and right (the second ., also "safe") - tiles on the previous row. Because all of the trap rules require a trap in at least one of - the previous three tiles, the first tile on this new row is also safe, .. - • The second character on the next row considers its left (.), center (.), and right (^) - tiles from the previous row. This matches the fourth rule: only the right tile is a trap. - Therefore, the next tile in this new row is a trap, ^. - • The third character considers .^^, which matches the second trap rule: its center and - right tiles are traps, but its left tile is not. Therefore, this tile is also a trap, ^. - • The last two characters in this new row match the first and third rules, respectively, and - so they are both also traps, ^. + • The leftmost character on the next row considers the left (nonexistent, + so we assume "safe"), center (the first ., which means "safe"), and right + (the second ., also "safe") tiles on the previous row. Because all of the + trap rules require a trap in at least one of the previous three tiles, the + first tile on this new row is also safe, .. - After these steps, we now know the next row of tiles in the room: .^^^^. Then, we continue on - to the next row, using the same rules, and get ^^..^. After determining two new rows, our map - looks like this: + • The second character on the next row considers its left (.), center (.), + and right (^) tiles from the previous row. This matches the fourth rule: + only the right tile is a trap. Therefore, the next tile in this new row is + a trap, ^. + + • The third character considers .^^, which matches the second trap rule: + its center and right tiles are traps, but its left tile is not. Therefore, + this tile is also a trap, ^. + + • The last two characters in this new row match the first and third rules, + respectively, and so they are both also traps, ^. + + After these steps, we now know the next row of tiles in the room: .^^^^. + Then, we continue on to the next row, using the same rules, and get ^^..^. + After determining two new rows, our map looks like this: ..^^. .^^^^ @@ -70,16 +80,16 @@ Advent of Code In ten rows, this larger example has 38 safe tiles. - Starting with the map in your puzzle input, in a total of 40 rows (including the starting - row), how many safe tiles are there? + Starting with the map in your puzzle input, in a total of 40 rows (including + the starting row), how many safe tiles are there? - Your puzzle answer ________. + Your puzzle answer 1913. --- Part Two --- How many safe tiles are there in a total of 400000 rows? - Your puzzle answer was ________. + Your puzzle answer was 19993564. References diff --git a/2016/day19/problem b/2016/day19/problem index 6397ccc..1d82834 100644 --- a/2016/day19/problem +++ b/2016/day19/problem @@ -5,10 +5,10 @@ Advent of Code The Elves contact you over a highly secure emergency channel. Back at the North Pole, the Elves are busy misunderstanding White Elephant parties. - Each Elf brings a present. They all sit in a circle, numbered starting - with position 1. Then, starting with the first Elf, they take turns - stealing all the presents from the Elf to their left. An Elf with no - presents is removed from the circle and does not take turns. + Each Elf brings a present. They all sit in a circle, numbered starting with + position 1. Then, starting with the first Elf, they take turns stealing all + the presents from the Elf to their left. An Elf with no presents is removed + from the circle and does not take turns. For example, with five Elves (numbered 1 to 5): @@ -27,21 +27,21 @@ Advent of Code So, with five Elves, the Elf that sits starting in position 3 gets all the presents. - With the number of Elves given in your puzzle input, which Elf gets all - the presents? + With the number of Elves given in your puzzle input, which Elf gets all the + presents? Your puzzle input was 3014387. - Your puzzle answer was __________. + Your puzzle answer was 1834471. --- Part Two --- Realizing the folly of their present-exchange rules, the Elves agree to - instead steal presents from the Elf directly across the circle. If two - Elves are across the circle, the one on the left (from the perspective of - the stealer) is stolen from. The other rules remain unchanged: Elves with - no presents are removed from the circle entirely, and the other elves move - in slightly to keep the circle evenly spaced. + instead steal presents from the Elf directly across the circle. If two Elves + are across the circle, the one on the left (from the perspective of the + stealer) is stolen from. The other rules remain unchanged: Elves with no + presents are removed from the circle entirely, and the other elves move in + slightly to keep the circle evenly spaced. For example, with five Elves (again numbered 1 to 5): @@ -52,8 +52,8 @@ Advent of Code 4 3 • Elves 3 and 4 are across the circle; Elf 3's present is stolen, being - the one to the left. Elf 3 leaves the circle, and the rest of the - Elves move in: + the one to the left. Elf 3 leaves the circle, and the rest of the Elves + move in: 1 1 5 2 --> 5 2 @@ -80,12 +80,12 @@ Advent of Code So, with five Elves, the Elf that sits starting in position 2 gets all the presents. - With the number of Elves given in your puzzle input, which Elf now gets - all the presents? + With the number of Elves given in your puzzle input, which Elf now gets all + the presents? Your puzzle input was 3014387. - Your puzzle answer was __________. + Your puzzle answer was 1420064. References diff --git a/2016/day20/problem b/2016/day20/problem index b46f68c..a037d1a 100644 --- a/2016/day20/problem +++ b/2016/day20/problem @@ -2,30 +2,37 @@ Advent of Code --- Day 20: Firewall Rules --- - You'd like to set up a small hidden computer here so you can use it to get back into the network later. However, the corporate firewall only allows communication with certain external - IP addresses. + You'd like to set up a small hidden computer here so you can use it to get + back into the network later. However, the corporate firewall only allows + communication with certain external IP addresses. - You've retrieved the list of blocked IPs from the firewall, but the list seems to be messy and poorly maintained, and it's not clear which IPs are allowed. Also, rather than being - written in dot-decimal notation, they are written as plain 32-bit integers, which can have any value from 0 through 4294967295, inclusive. + You've retrieved the list of blocked IPs from the firewall, but the list + seems to be messy and poorly maintained, and it's not clear which IPs are + allowed. Also, rather than being written in dot-decimal notation, they are + written as plain 32-bit integers, which can have any value from 0 through + 4294967295, inclusive. - For example, suppose only the values 0 through 9 were valid, and that you retrieved the following blacklist: + For example, suppose only the values 0 through 9 were valid, and that you + retrieved the following blacklist: 5-8 0-2 4-7 - The blacklist specifies ranges of IPs (inclusive of both the start and end value) that are not allowed. Then, the only IPs that this firewall allows are 3 and 9, since those are the - only numbers not in any range. + The blacklist specifies ranges of IPs (inclusive of both the start and end + value) that are not allowed. Then, the only IPs that this firewall allows + are 3 and 9, since those are the only numbers not in any range. - Given the list of blocked IPs you retrieved from the firewall (your puzzle input), what is the lowest-valued IP that is not blocked? + Given the list of blocked IPs you retrieved from the firewall (your puzzle + input), what is the lowest-valued IP that is not blocked? - Your puzzle answer was _______________. + Your puzzle answer was 31053880. --- Part Two --- How many IPs are allowed by the blacklist? - Your puzzle answer was _______________. + Your puzzle answer was 117. References diff --git a/2016/day21/problem b/2016/day21/problem index 52e8c26..a263d8c 100644 --- a/2016/day21/problem +++ b/2016/day21/problem @@ -2,51 +2,86 @@ Advent of Code --- Day 21: Scrambled Letters and Hash --- - The computer system you're breaking into uses a weird scrambling function to store its passwords. It shouldn't be much trouble to create - your own scrambled password so you can add it to the system; you just have to implement the scrambler. + The computer system you're breaking into uses a weird scrambling function to + store its passwords. It shouldn't be much trouble to create your own + scrambled password so you can add it to the system; you just have to + implement the scrambler. - The scrambling function is a series of operations (the exact list is provided in your puzzle input). Starting with the password to be - scrambled, apply each operation in succession to the string. The individual operations behave as follows: + The scrambling function is a series of operations (the exact list is + provided in your puzzle input). Starting with the password to be scrambled, + apply each operation in succession to the string. The individual operations + behave as follows: - • swap position X with position Y means that the letters at indexes X and Y (counting from 0) should be swapped. - • swap letter X with letter Y means that the letters X and Y should be swapped (regardless of where they appear in the string). - • rotate left/right X steps means that the whole string should be rotated; for example, one right rotation would turn abcd into dabc. - • rotate based on position of letter X means that the whole string should be rotated to the right based on the index of letter X - (counting from 0) as determined before this instruction does any rotations. Once the index is determined, rotate the string to the - right one time, plus a number of times equal to that index, plus one additional time if the index was at least 4. - • reverse positions X through Y means that the span of letters at indexes X through Y (including the letters at X and Y) should be - reversed in order. - • move position X to position Y means that the letter which is at index X should be removed from the string, then inserted such that - it ends up at index Y. + • swap position X with position Y means that the letters at indexes X and + Y (counting from 0) should be swapped. - For example, suppose you start with abcde and perform the following operations: + • swap letter X with letter Y means that the letters X and Y should be + swapped (regardless of where they appear in the string). + + • rotate left/right X steps means that the whole string should be rotated; + for example, one right rotation would turn abcd into dabc. + + • rotate based on position of letter X means that the whole string should + be rotated to the right based on the index of letter X (counting from 0) + as determined before this instruction does any rotations. Once the index + is determined, rotate the string to the right one time, plus a number of + times equal to that index, plus one additional time if the index was at + least 4. + + • reverse positions X through Y means that the span of letters at indexes + X through Y (including the letters at X and Y) should be reversed in + order. + + • move position X to position Y means that the letter which is at index X + should be removed from the string, then inserted such that it ends up at + index Y. + + For example, suppose you start with abcde and perform the following + operations: + + • swap position 4 with position 0 swaps the first and last letters, + producing the input for the next step, ebcda. - • swap position 4 with position 0 swaps the first and last letters, producing the input for the next step, ebcda. • swap letter d with letter b swaps the positions of d and b: edcba. - • reverse positions 0 through 4 causes the entire string to be reversed, producing abcde. - • rotate left 1 step shifts all letters left one position, causing the first letter to wrap to the end of the string: bcdea. - • move position 1 to position 4 removes the letter at position 1 (c), then inserts it at position 4 (the end of the string): bdeac. - • move position 3 to position 0 removes the letter at position 3 (a), then inserts it at position 0 (the front of the string): abdec. - • rotate based on position of letter b finds the index of letter b (1), then rotates the string right once plus a number of times - equal to that index (2): ecabd. - • rotate based on position of letter d finds the index of letter d (4), then rotates the string right once, plus a number of times - equal to that index, plus an additional time because the index was at least 4, for a total of 6 right rotations: decab. + + • reverse positions 0 through 4 causes the entire string to be reversed, + producing abcde. + + • rotate left 1 step shifts all letters left one position, causing the + first letter to wrap to the end of the string: bcdea. + + • move position 1 to position 4 removes the letter at position 1 (c), then + inserts it at position 4 (the end of the string): bdeac. + + • move position 3 to position 0 removes the letter at position 3 (a), then + inserts it at position 0 (the front of the string): abdec. + + • rotate based on position of letter b finds the index of letter b (1), + then rotates the string right once plus a number of times equal to that + index (2): ecabd. + + • rotate based on position of letter d finds the index of letter d (4), + then rotates the string right once, plus a number of times equal to that + index, plus an additional time because the index was at least 4, for a + total of 6 right rotations: decab. After these steps, the resulting scrambled password is decab. - Now, you just need to generate a new scrambled password and you can access the system. Given the list of scrambling operations in your - puzzle input, what is the result of scrambling abcdefgh? + Now, you just need to generate a new scrambled password and you can access + the system. Given the list of scrambling operations in your puzzle input, + what is the result of scrambling abcdefgh? - Your puzzle answer was ________. + Your puzzle answer was cbeghdaf. --- Part Two --- - You scrambled the password correctly, but you discover that you can't actually modify the password file on the system. You'll need to - un-scramble one of the existing passwords by reversing the scrambling process. + You scrambled the password correctly, but you discover that you can't + actually modify the password file on the system. You'll need to un-scramble + one of the existing passwords by reversing the scrambling process. What is the un-scrambled version of the scrambled password fbgdceah? - Your puzzle answer was ________. + Your puzzle answer was bacdefgh. References diff --git a/2016/day22/problem b/2016/day22/problem new file mode 100644 index 0000000..26e0a28 --- /dev/null +++ b/2016/day22/problem @@ -0,0 +1,176 @@ +Advent of Code + +--- Day 22: Grid Computing --- + + You gain access to a massive storage cluster arranged in a grid; each + storage node is only connected to the four nodes directly adjacent to it + (three if the node is on an edge, two if it's in a corner). + + You can directly access data only on node /dev/grid/node-x0-y0, but you can + perform some limited actions on the other nodes: + + • You can get the disk usage of all nodes (via df). The result of doing + this is in your puzzle input. + + • You can instruct a node to move (not copy) all of its data to an + adjacent node (if the destination node has enough space to receive the + data). The sending node is left empty after this operation. + + Nodes are named by their position: the node named node-x10-y10 is adjacent + to nodes node-x9-y10, node-x11-y10, node-x10-y9, and node-x10-y11. + + Before you begin, you need to understand the arrangement of data on these + nodes. Even though you can only move data between directly connected nodes, + you're going to need to rearrange a lot of the data to get access to the + data you need. Therefore, you need to work out how you might be able to + shift data around. + + To do this, you'd like to count the number of viable pairs of nodes. A + viable pair is any two nodes (A,B), regardless of whether they are directly + connected, such that: + + • Node A is not empty (its Used is not zero). + + • Nodes A and B are not the same node. + + • The data on node A (its Used) would fit on node B (its Avail). + + How many viable pairs of nodes are there? + + Your puzzle answer was 955. + +--- Part Two --- + + Now that you have a better understanding of the grid, it's time to get to + work. + + Your goal is to gain access to the data which begins in the node with y=0 + and the highest x (that is, the node in the top-right corner). + + For example, suppose you have the following grid: + + Filesystem Size Used Avail Use% + /dev/grid/node-x0-y0 10T 8T 2T 80% + /dev/grid/node-x0-y1 11T 6T 5T 54% + /dev/grid/node-x0-y2 32T 28T 4T 87% + /dev/grid/node-x1-y0 9T 7T 2T 77% + /dev/grid/node-x1-y1 8T 0T 8T 0% + /dev/grid/node-x1-y2 11T 7T 4T 63% + /dev/grid/node-x2-y0 10T 6T 4T 60% + /dev/grid/node-x2-y1 9T 8T 1T 88% + /dev/grid/node-x2-y2 9T 6T 3T 66% + + In this example, you have a storage grid 3 nodes wide and 3 nodes tall. The + node you can access directly, node-x0-y0, is almost full. The node + containing the data you want to access, node-x2-y0 (because it has y=0 and + the highest x value), contains 6 terabytes of data - enough to fit on your + node, if only you could make enough space to move it there. + + Fortunately, node-x1-y1 looks like it has enough free space to enable you to + move some of this data around. In fact, it seems like all of the nodes have + enough space to hold any node's data (except node-x0-y2, which is much + larger, very full, and not moving any time soon). So, initially, the grid's + capacities and connections look like this: + + ( 8T/10T) -- 7T/ 9T -- [ 6T/10T] + | | | + 6T/11T -- 0T/ 8T -- 8T/ 9T + | | | + 28T/32T -- 7T/11T -- 6T/ 9T + + The node you can access directly is in parentheses; the data you want starts + in the node marked by square brackets. + + In this example, most of the nodes are interchangable: they're full enough + that no other node's data would fit, but small enough that their data could + be moved around. Let's draw these nodes as .. The exceptions are the empty + node, which we'll draw as _, and the very large, very full node, which we'll + draw as #. Let's also draw the goal data as G. Then, it looks like this: + + (.) . G + . _ . + # . . + + The goal is to move the data in the top right, G, to the node in + parentheses. To do this, we can issue some commands to the grid and + rearrange the data: + + • Move data from node-y0-x1 to node-y1-x1, leaving node node-y0-x1 empty: + + (.) _ G + . . . + # . . + + • Move the goal data from node-y0-x2 to node-y0-x1: + + (.) G _ + . . . + # . . + + • At this point, we're quite close. However, we have no deletion command, + so we have to move some more data around. So, next, we move the data from + node-y1-x2 to node-y0-x2: + + (.) G . + . . _ + # . . + + • Move the data from node-y1-x1 to node-y1-x2: + + (.) G . + . _ . + # . . + + • Move the data from node-y1-x0 to node-y1-x1: + + (.) G . + _ . . + # . . + + • Next, we can free up space on our node by moving the data from + node-y0-x0 to node-y1-x0: + + (_) G . + . . . + # . . + + • Finally, we can access the goal data by moving the it from node-y0-x1 to + node-y0-x0: + + (G) _ . + . . . + # . . + + So, after 7 steps, we've accessed the data we want. Unfortunately, each of + these moves takes time, and we need to be efficient: + + What is the fewest number of steps required to move your goal data to + node-x0-y0? + + Your puzzle answer was 246. + + 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 + . http://adventofcode.com/ + . http://adventofcode.com/2016/about + . http://adventofcode.com/2016/support + . http://adventofcode.com/2016/events + . http://adventofcode.com/2016/settings + . http://adventofcode.com/2016/auth/logout + . http://adventofcode.com/2016 + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/leaderboard + . http://adventofcode.com/2016/stats + . http://adventofcode.com/2016/sponsors + . http://adventofcode.com/2016/sponsors + . https://en.wikipedia.org/wiki/Df_(Unix)#Example + . https://en.wikipedia.org/wiki/Terabyte + . http://adventofcode.com/2016 + . http://adventofcode.com/2016/day/22/input diff --git a/2016/day23/problem b/2016/day23/problem index b42a03a..8aae749 100644 --- a/2016/day23/problem +++ b/2016/day23/problem @@ -2,34 +2,50 @@ Advent of Code --- Day 23: Safe Cracking --- - This is one of the top floors of the nicest tower in EBHQ. The Easter Bunny's private office is here, complete with - a safe hidden behind a painting, and who wouldn't hide a star in a safe behind a painting? + This is one of the top floors of the nicest tower in EBHQ. The Easter + Bunny's private office is here, complete with a safe hidden behind a + painting, and who wouldn't hide a star in a safe behind a painting? - The safe has a digital screen and keypad for code entry. A sticky note attached to the safe has a password hint on - it: "eggs". The painting is of a large rabbit coloring some eggs. You see 7. + The safe has a digital screen and keypad for code entry. A sticky note + attached to the safe has a password hint on it: "eggs". The painting is of a + large rabbit coloring some eggs. You see 7. - When you go to type the code, though, nothing appears on the display; instead, the keypad comes apart in your - hands, apparently having been smashed. Behind it is some kind of socket - one that matches a connector in your - prototype computer! You pull apart the smashed keypad and extract the logic circuit, plug it into your computer, - and plug your computer into the safe. + When you go to type the code, though, nothing appears on the display; + instead, the keypad comes apart in your hands, apparently having been + smashed. Behind it is some kind of socket - one that matches a connector in + your prototype computer! You pull apart the smashed keypad and extract the + logic circuit, plug it into your computer, and plug your computer into the + safe. - Now, you just need to figure out what output the keypad would have sent to the safe. You extract the assembunny - code from the logic chip (your puzzle input). + Now, you just need to figure out what output the keypad would have sent to + the safe. You extract the assembunny code from the logic chip (your puzzle + input). - The code looks like it uses almost the same architecture and instruction set that the monorail computer used! You - should be able to use the same assembunny interpreter for this as you did there, but with one new instruction: + The code looks like it uses almost the same architecture and instruction set + that the monorail computer used! You should be able to use the same + assembunny interpreter for this as you did there, but with one new + instruction: - tgl x toggles the instruction x away (pointing at instructions like jnz does: positive means forward; negative - means backward): + tgl x toggles the instruction x away (pointing at instructions like jnz + does: positive means forward; negative means backward): + + • For one-argument instructions, inc becomes dec, and all other + one-argument instructions become inc. + + • For two-argument instructions, jnz becomes cpy, and all other + two-instructions become jnz. - • For one-argument instructions, inc becomes dec, and all other one-argument instructions become inc. - • For two-argument instructions, jnz becomes cpy, and all other two-instructions become jnz. • The arguments of a toggled instruction are not affected. - • If an attempt is made to toggle an instruction outside the program, nothing happens. - • If toggling produces an invalid instruction (like cpy 1 2) and an attempt is later made to execute that - instruction, skip it instead. - • If tgl toggles itself (for example, if a is 0, tgl a would target itself and become inc a), the resulting - instruction is not executed until the next time it is reached. + + • If an attempt is made to toggle an instruction outside the program, + nothing happens. + + • If toggling produces an invalid instruction (like cpy 1 2) and an + attempt is later made to execute that instruction, skip it instead. + + • If tgl toggles itself (for example, if a is 0, tgl a would target itself + and become inc a), the resulting instruction is not executed until the + next time it is reached. For example, given this program: @@ -42,34 +58,45 @@ Advent of Code dec a • cpy 2 a initializes register a to 2. - • The first tgl a toggles an instruction a (2) away from it, which changes the third tgl a into inc a. - • The second tgl a also modifies an instruction 2 away from it, which changes the cpy 1 a into jnz 1 a. + + • The first tgl a toggles an instruction a (2) away from it, which changes + the third tgl a into inc a. + + • The second tgl a also modifies an instruction 2 away from it, which + changes the cpy 1 a into jnz 1 a. + • The fourth line, which is now inc a, increments a to 3. - • Finally, the fifth line, which is now jnz 1 a, jumps a (3) instructions ahead, skipping the dec a instructions. + + • Finally, the fifth line, which is now jnz 1 a, jumps a (3) instructions + ahead, skipping the dec a instructions. In this example, the final value in register a is 3. - The rest of the electronics seem to place the keypad entry (the number of eggs, 7) in register a, run the code, and - then send the value left in register a to the safe. + The rest of the electronics seem to place the keypad entry (the number of + eggs, 7) in register a, run the code, and then send the value left in + register a to the safe. What value should be sent to the safe? - Your puzzle answer was ________. + Your puzzle answer was 10584. --- Part Two --- - The safe doesn't open, but it does make several angry noises to express its frustration. + The safe doesn't open, but it does make several angry noises to express its + frustration. - You're quite sure your logic is working correctly, so the only other thing is... you check the painting again. As - it turns out, colored eggs are still eggs. Now you count 12. + You're quite sure your logic is working correctly, so the only other thing + is... you check the painting again. As it turns out, colored eggs are still + eggs. Now you count 12. - As you run the program with this new input, the prototype computer begins to overheat. You wonder what's taking so - long, and whether the lack of any instruction more powerful than "add one" has anything to do with it. Don't + As you run the program with this new input, the prototype computer begins to + overheat. You wonder what's taking so long, and whether the lack of any + instruction more powerful than "add one" has anything to do with it. Don't bunnies usually multiply? Anyway, what value should actually be sent to the safe? - Your puzzle answer was ____________. + Your puzzle answer was 479007144. References diff --git a/2016/day24/problem b/2016/day24/problem index 92592ac..8bf8a43 100644 --- a/2016/day24/problem +++ b/2016/day24/problem @@ -2,19 +2,23 @@ Advent of Code --- Day 24: Air Duct Spelunking --- - You've finally met your match; the doors that provide access to the roof are locked tight, and all of the controls and - related electronics are inaccessible. You simply can't reach them. + You've finally met your match; the doors that provide access to the roof are + locked tight, and all of the controls and related electronics are + inaccessible. You simply can't reach them. The robot that cleans the air ducts, however, can. - It's not a very fast little robot, but you reconfigure it to be able to interface with some of the exposed wires that - have been routed through the HVAC system. If you can direct it to each of those locations, you should be able to bypass - the security controls. + It's not a very fast little robot, but you reconfigure it to be able to + interface with some of the exposed wires that have been routed through the + HVAC system. If you can direct it to each of those locations, you should be + able to bypass the security controls. - You extract the duct layout for this area from some blueprints you acquired and create a map with the relevant locations - marked (your puzzle input). 0 is your current location, from which the cleaning robot embarks; the other numbers are (in - no particular order) the locations the robot needs to visit at least once each. Walls are marked as #, and open passages - are marked as .. Numbers behave like open passages. + You extract the duct layout for this area from some blueprints you acquired + and create a map with the relevant locations marked (your puzzle input). 0 + is your current location, from which the cleaning robot embarks; the other + numbers are (in no particular order) the locations the robot needs to visit + at least once each. Walls are marked as #, and open passages are marked as + .. Numbers behave like open passages. For example, suppose you have a map like the following: @@ -24,29 +28,33 @@ Advent of Code #4.......3# ########### - To reach all of the points of interest as quickly as possible, you would have the robot take the following path: + To reach all of the points of interest as quickly as possible, you would + have the robot take the following path: • 0 to 4 (2 steps) • 4 to 1 (4 steps; it can't move diagonally) • 1 to 2 (6 steps) • 2 to 3 (2 steps) - Since the robot isn't very fast, you need to find it the shortest route. This path is the fewest steps (in the above - example, a total of 14) required to start at 0 and then visit every other location at least once. + Since the robot isn't very fast, you need to find it the shortest route. + This path is the fewest steps (in the above example, a total of 14) required + to start at 0 and then visit every other location at least once. - Given your actual map, and starting from location 0, what is the fewest number of steps required to visit every non-0 - number marked on the map at least once? + Given your actual map, and starting from location 0, what is the fewest + number of steps required to visit every non-0 number marked on the map at + least once? - Your puzzle answer was ____. + Your puzzle answer was 490. --- Part Two --- - Of course, if you leave the cleaning robot somewhere weird, someone is bound to notice. + Of course, if you leave the cleaning robot somewhere weird, someone is bound + to notice. - What is the fewest number of steps required to start at 0, visit every non-0 number marked on the map at least once, and - then return to 0? + What is the fewest number of steps required to start at 0, visit every non-0 + number marked on the map at least once, and then return to 0? - Your puzzle answer was _____. + Your puzzle answer was 744. References diff --git a/2016/day25/problem b/2016/day25/problem index a07888e..7462c28 100644 --- a/2016/day25/problem +++ b/2016/day25/problem @@ -2,51 +2,61 @@ Advent of Code --- Day 25: Clock Signal --- - You open the door and find yourself on the roof. The city sprawls away from you for miles and miles. + You open the door and find yourself on the roof. The city sprawls away from + you for miles and miles. - There's not much time now - it's already Christmas, but you're nowhere near the North Pole, much too far to deliver - these stars to the sleigh in time. + There's not much time now - it's already Christmas, but you're nowhere near + the North Pole, much too far to deliver these stars to the sleigh in time. - However, maybe the huge antenna up here can offer a solution. After all, the sleigh doesn't need the stars, exactly; it - needs the timing data they provide, and you happen to have a massive signal generator right here. + However, maybe the huge antenna up here can offer a solution. After all, the + sleigh doesn't need the stars, exactly; it needs the timing data they + provide, and you happen to have a massive signal generator right here. - You connect the stars you have to your prototype computer, connect that to the antenna, and begin the transmission. + You connect the stars you have to your prototype computer, connect that to + the antenna, and begin the transmission. Nothing happens. - You call the service number printed on the side of the antenna and quickly explain the situation. "I'm not sure what - kind of equipment you have connected over there," he says, "but you need a clock signal." You try to explain that this - is a signal for a clock. + You call the service number printed on the side of the antenna and quickly + explain the situation. "I'm not sure what kind of equipment you have + connected over there," he says, "but you need a clock signal." You try to + explain that this is a signal for a clock. - "No, no, a clock signal - timing information so the antenna computer knows how to read the data you're sending it. An - endless, alternating pattern of 0, 1, 0, 1, 0, 1, 0, 1, 0, 1...." He trails off. + "No, no, a clock signal - timing information so the antenna computer knows + how to read the data you're sending it. An endless, alternating pattern of + 0, 1, 0, 1, 0, 1, 0, 1, 0, 1...." He trails off. - You ask if the antenna can handle a clock signal at the frequency you would need to use for the data from the stars. - "There's no way it can! The only antenna we've installed capable of that is on top of a top-secret Easter Bunny - installation, and you're definitely not-" You hang up the phone. + You ask if the antenna can handle a clock signal at the frequency you would + need to use for the data from the stars. "There's no way it can! The only + antenna we've installed capable of that is on top of a top-secret Easter + Bunny installation, and you're definitely not-" You hang up the phone. - You've extracted the antenna's clock signal generation assembunny code (your puzzle input); it looks mostly compatible - with code you worked on just recently. + You've extracted the antenna's clock signal generation assembunny code (your + puzzle input); it looks mostly compatible with code you worked on just + recently. This antenna code, being a signal generator, uses one extra instruction: - • out x transmits x (either an integer or the value of a register) as the next value for the clock signal. + • out x transmits x (either an integer or the value of a register) as the + next value for the clock signal. - The code takes a value (via register a) that describes the signal to generate, but you're not sure how it's used. You'll - have to find the input to produce the right signal through experimentation. + The code takes a value (via register a) that describes the signal to + generate, but you're not sure how it's used. You'll have to find the input + to produce the right signal through experimentation. - What is the lowest positive integer that can be used to initialize register a and cause the code to output a clock - signal of 0, 1, 0, 1... repeating forever? + What is the lowest positive integer that can be used to initialize register + a and cause the code to output a clock signal of 0, 1, 0, 1... repeating + forever? - Your puzzle answer was ____. + Your puzzle answer was 175. --- Part Two --- - The antenna is ready. Now, all you need is the fifty stars required to generate the signal for the sleigh, but you don't - have enough. + The antenna is ready. Now, all you need is the fifty stars required to + generate the signal for the sleigh, but you don't have enough. - You look toward the sky in desperation... suddenly noticing that a lone star has been installed at the top of the - antenna! Only 49 more to go. + You look toward the sky in desperation... suddenly noticing that a lone star + has been installed at the top of the antenna! Only 49 more to go. If you like, you can [ [Retransmit the Signal] ] .