Reflowed problems and added solutions

This commit is contained in:
Brian Buller 2018-03-15 11:24:23 -05:00
parent 986d17f104
commit 2a37946673
50 changed files with 2124 additions and 1464 deletions

View File

@ -1,34 +1,27 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 1: Not Quite Lisp --- --- Day 1: Not Quite Lisp ---
Santa was hoping for a white Christmas, but his weather machine's "snow" function is powered by Santa was hoping for a white Christmas, but his weather machine's "snow"
stars, and he's fresh out! To save Christmas, he needs you to collect fifty stars by December function is powered by stars, and he's fresh out! To save Christmas, he
25th. 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 Collect stars by helping Santa solve puzzles. Two puzzles will be made
the advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle available on each day in the advent calendar; the second puzzle is unlocked
grants one star. Good luck! when you complete the first. Each puzzle grants one star. Good luck!
Here's an easy puzzle to warm you up. 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 Santa is trying to deliver presents in a large apartment building, but he
floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) can't find the right floor - the directions he got are a little confusing.
and then follows the instructions one character at a time. 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 An opening parenthesis, (, means he should go up one floor, and a closing
he should go down one floor. 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 The apartment building is very tall, and the basement is very deep; he will
or bottom floors. never find the top or bottom floors.
For example: For example:
@ -44,16 +37,17 @@
--- Part Two --- --- Part Two ---
Now, given the same instructions, find the position of the first character that causes him to Now, given the same instructions, find the position of the first character
enter the basement (floor -1). The first character in the instructions has position 1, the that causes him to enter the basement (floor -1). The first character in the
second character has position 2, and so on. instructions has position 1, the second character has position 2, and so on.
For example: For example:
• ) causes him to enter the basement at character position 1. • ) causes him to enter the basement at character position 1.
• ()()) causes him to enter the basement at character position 5. • ()()) 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. Your puzzle answer was 1771.
@ -63,8 +57,6 @@
If you still want to see it, you can get your puzzle input. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -76,6 +68,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/1/input . 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

View File

@ -1,52 +1,54 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 2: I Was Told There Would Be No Math --- --- 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 The elves are running low on wrapping paper, and so they need to submit an
have a list of the dimensions (length l, width w, and height h) of each present, and only want order for more. They have a list of the dimensions (length l, width w, and
to order exactly as much as they need. 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 Fortunately, every present is a box (a perfect right rectangular prism),
calculating the required wrapping paper for each gift a little easier: find the surface area of which makes calculating the required wrapping paper for each gift a little
the box, which is 2*l*w + 2*w*h + 2*h*l. The elves also need a little extra paper for each easier: find the surface area of the box, which is 2*l*w + 2*w*h + 2*h*l.
present: the area of the smallest side. The elves also need a little extra paper for each present: the area of the
smallest side.
For example: For example:
 A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square feet of wrapping  A present with dimensions 2x3x4 requires 2*6 + 2*12 + 2*8 = 52 square
paper plus 6 square feet of slack, for a total of 58 square feet. feet of wrapping paper plus 6 square feet of slack, for a total of 58
 A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square feet of wrapping square feet.
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  A present with dimensions 1x1x10 requires 2*1 + 2*10 + 2*10 = 42 square
they order? 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. Your puzzle answer was 1588178.
--- Part Two --- --- Part Two ---
The elves are also running low on ribbon. Ribbon is all the same width, so they only have to The elves are also running low on ribbon. Ribbon is all the same width, so
worry about the length they need to order, which they would again like to be exact. 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 The ribbon required to wrap a present is the shortest distance around its
smallest perimeter of any one face. Each present also requires a bow made out of ribbon as sides, or the smallest perimeter of any one face. Each present also requires
well; the feet of ribbon required for the perfect bow is equal to the cubic feet of volume of a bow made out of ribbon as well; the feet of ribbon required for the
the present. Don't ask how they tie the bow, though; they'll never tell. 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: For example:
 A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to wrap the present  A present with dimensions 2x3x4 requires 2+2+3+3 = 10 feet of ribbon to
plus 2*3*4 = 24 feet of ribbon for the bow, for a total of 34 feet. wrap the present plus 2*3*4 = 24 feet of ribbon for the bow, for a total
 A present with dimensions 1x1x10 requires 1+1+1+1 = 4 feet of ribbon to wrap the present of 34 feet.
plus 1*1*10 = 10 feet of ribbon for the bow, for a total of 14 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? 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: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -72,6 +73,3 @@ References
. https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid . https://en.wikipedia.org/wiki/Cuboid#Rectangular_cuboid
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/2/input . 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

View File

@ -1,64 +1,64 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 3: Perfectly Spherical Houses in a Vacuum --- --- Day 3: Perfectly Spherical Houses in a Vacuum ---
Santa is delivering presents to an infinite two-dimensional grid of houses. 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 He begins by delivering a present to the house at his starting location, and
North Pole calls him via radio and tells him where to move next. Moves are always exactly one then an elf at the North Pole calls him via radio and tells him where to
house to the north (^), south (v), east (>), or west (<). After each move, he delivers another move next. Moves are always exactly one house to the north (^), south (v),
present to the house at his new location. 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 However, the elf back at the north pole has had a little too much eggnog,
are a little off, and Santa ends up visiting some houses more than once. How many houses and so his directions are a little off, and Santa ends up visiting some
receive at least one present? houses more than once. How many houses receive at least one present?
For example: For example:
• > delivers presents to 2 houses: one at the starting location, and one to the east. • > delivers presents to 2 houses: one at the starting location, and one
• ^>v< delivers presents to 4 houses in a square, including twice to the house at his to the east.
starting/ending location.
• ^v^v^v^v^v delivers a bunch of presents to some very lucky children at only 2 houses. • ^>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. Your puzzle answer was 2572.
--- Part Two --- --- Part Two ---
The next year, to speed up the process, Santa creates a robot version of himself, Robo-Santa, The next year, to speed up the process, Santa creates a robot version of
to deliver presents with him. himself, Robo-Santa, to deliver presents with him.
Santa and Robo-Santa start at the same location (delivering two presents to the same starting Santa and Robo-Santa start at the same location (delivering two presents to
house), then take turns moving based on instructions from the elf, who is eggnoggedly reading the same starting house), then take turns moving based on instructions from
from the same script as the previous year. the elf, who is eggnoggedly reading from the same script as the previous
year.
This year, how many houses receive at least one present? This year, how many houses receive at least one present?
For example: For example:
• ^v delivers presents to 3 houses, because Santa goes north, and then Robo-Santa goes south. • ^v delivers presents to 3 houses, because Santa goes north, and then
• ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up back where they Robo-Santa goes south.
started.
• ^v^v^v^v^v now delivers presents to 11 houses, with Santa going one direction and • ^>v< now delivers presents to 3 houses, and Santa and Robo-Santa end up
Robo-Santa going the other. 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. Your puzzle answer was 2631.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -70,6 +70,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/3/input . 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

View File

@ -1,30 +1,25 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 4: The Ideal Stocking Stuffer --- --- Day 4: The Ideal Stocking Stuffer ---
Santa needs help mining some AdventCoins (very similar to bitcoins) to use as gifts for all the Santa needs help mining some AdventCoins (very similar to bitcoins) to use
economically forward-thinking little girls and boys. 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. To do this, he needs to find MD5 hashes which, in hexadecimal, start with at
The input to the MD5 hash is some secret key (your puzzle input, given below) followed by a least five zeroes. The input to the MD5 hash is some secret key (your puzzle
number in decimal. To mine AdventCoins, you must find Santa the lowest positive number (no input, given below) followed by a number in decimal. To mine AdventCoins,
leading zeroes: 1, 2, 3, ...) that produces such a hash. you must find Santa the lowest positive number (no leading zeroes: 1, 2, 3,
...) that produces such a hash.
For example: For example:
 If your secret key is abcdef, the answer is 609043, because the MD5 hash of abcdef609043  If your secret key is abcdef, the answer is 609043, because the MD5 hash
starts with five zeroes (000001dbbfa...), and it is the lowest such number to do so. of abcdef609043 starts with five zeroes (000001dbbfa...), and it is the
 If your secret key is pqrstuv, the lowest number it combines with to make an MD5 hash lowest such number to do so.
starting with five zeroes is 1048970; that is, the MD5 hash of pqrstuv1048970 looks like
000006136ef....  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. Your puzzle answer was 282749.
@ -36,12 +31,11 @@
Both parts of this puzzle are complete! They provide two gold stars: ** 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. Your puzzle input was yzbqklnj.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -56,6 +50,3 @@ References
. https://en.wikipedia.org/wiki/MD5 . https://en.wikipedia.org/wiki/MD5
. https://en.wikipedia.org/wiki/Hexadecimal . https://en.wikipedia.org/wiki/Hexadecimal
. http://adventofcode.com/ . 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

View File

@ -1,33 +1,34 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 5: Doesn't He Have Intern-Elves For This? --- --- 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: 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 three vowels (aeiou only), like aei, xazegov, or
 It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aeiouaeiouaeiou.
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  It contains at least one letter that appears twice in a row, like xx,
other requirements. 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: For example:
 ugknbfddgicrmopn is nice because it has at least three vowels (u...i...o...), a double  ugknbfddgicrmopn is nice because it has at least three vowels
letter (...dd...), and none of the disallowed substrings. (u...i...o...), a double letter (...dd...), and none of the disallowed
 aaa is nice because it has at least three vowels and a double letter, even though the substrings.
letters used by different rules overlap.
 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.  jchzalrnumimnmhp is naughty because it has no double letter.
 haegwjzuvuyypxyu is naughty because it contains the string xy.  haegwjzuvuyypxyu is naughty because it contains the string xy.
 dvszwmarrgswjxmb is naughty because it contains only one vowel.  dvszwmarrgswjxmb is naughty because it contains only one vowel.
How many strings are nice? How many strings are nice?
@ -36,26 +37,33 @@
--- Part Two --- --- Part Two ---
Realizing the error of his ways, Santa has switched to a better model of determining whether a Realizing the error of his ways, Santa has switched to a better model of
string is naughty or nice. None of the old rules apply, as they are all clearly ridiculous. 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: 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  It contains a pair of any two letters that appears at least twice in the
overlapping, like xyxy (xy) or aabcdefgaa (aa), but not like aaa (aa, but it overlaps). string without overlapping, like xyxy (xy) or aabcdefgaa (aa), but not
 It contains at least one letter which repeats with exactly one letter between them, like like aaa (aa, but it overlaps).
xyx, abcdefeghi (efe), or even aaa.
 It contains at least one letter which repeats with exactly one letter
between them, like xyx, abcdefeghi (efe), or even aaa.
For example: For example:
 qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj) and a letter that  qjhvhtzxzqqjkmpb is nice because is has a pair that appears twice (qj)
repeats with exactly one letter between them (zxz). 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.  xxyxx is nice because it has a pair that appears twice and a letter that
 uurcxstgmygtbstg is naughty because it has a pair (tg) but no repeat with a single letter repeats with one between, even though the letters used by each rule
between them. overlap.
 ieodomkazucvgmuy is naughty because it has a repeating letter with one between (odo), but
no pair that appears twice.  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? 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: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -80,6 +87,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/5/input . 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

View File

@ -1,36 +1,33 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 6: Probably a Fire Hazard --- --- Day 6: Probably a Fire Hazard ---
Because your neighbors keep defeating you in the holiday house decorating contest year after Because your neighbors keep defeating you in the holiday house decorating
year, you've decided to deploy one million lights in a 1000x1000 grid. 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 Furthermore, because you've been especially nice this year, Santa has mailed
on how to display the ideal lighting configuration. 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 Lights in your grid are numbered from 0 to 999 in each direction; the lights
at 0,0, 0,999, 999,999, and 999,0. The instructions include whether to turn on, turn off, or at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions
toggle various inclusive ranges given as coordinate pairs. Each coordinate pair represents include whether to turn on, turn off, or toggle various inclusive ranges
opposite corners of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore 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. 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 To defeat your neighbors this year, all you have to do is set up your lights
instructions Santa sent you in order. by doing the instructions Santa sent you in order.
For example: For example:
 turn on 0,0 through 999,999 would turn on (or leave on) every light.  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.  toggle 0,0 through 999,0 would toggle the first line of 1000 lights,
 turn off 499,499 through 500,500 would turn off (or leave off) the middle four 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? After following the instructions, how many lights are lit?
@ -38,36 +35,40 @@
--- Part Two --- --- Part Two ---
You just finish implementing your winning light pattern when you realize you mistranslated You just finish implementing your winning light pattern when you realize you
Santa's message from Ancient Nordic Elvish. mistranslated Santa's message from Ancient Nordic Elvish.
The light grid you bought actually has individual brightness controls; each light can have a The light grid you bought actually has individual brightness controls; each
brightness of zero or more. The lights all start at zero. 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 The phrase turn off actually means that you should decrease the brightness
1, to a minimum of zero. 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: For example:
 turn on 0,0 through 0,0 would increase the total brightness by 1.  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. Your puzzle answer was 14110788.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -79,6 +80,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/6/input . 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

View File

@ -1,39 +1,38 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 7: Some Assembly Required --- --- Day 7: Some Assembly Required ---
This year, Santa brought little Bobby Tables a set of wires and bitwise logic gates! This year, Santa brought little Bobby Tables a set of wires and bitwise
Unfortunately, little Bobby is a little under the recommended age range, and he needs help logic gates! Unfortunately, little Bobby is a little under the recommended
assembling the circuit. 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 Each wire has an identifier (some lowercase letters) and can carry a 16-bit
from 0 to 65535). A signal is provided to each wire by a gate, another wire, or some specific signal (a number from 0 to 65535). A signal is provided to each wire by a
value. Each wire can only get a signal from one source, but can provide its signal to multiple gate, another wire, or some specific value. Each wire can only get a signal
destinations. A gate provides no signal until all of its inputs have 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 The included instructions booklet describes how to connect the parts
means to connect wires x and y to an AND gate, and then connect its output to wire z. 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: For example:
 123 -> x means that the signal 123 is provided to wire x.  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,  x AND y -> z means that the bitwise AND of wire x and wire y is provided
you'd like to emulate the circuit instead, almost all programming languages (for example, C, to wire z.
JavaScript, or Python) provide operators for these gates.
 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: For example, here is a simple circuit:
@ -57,26 +56,26 @@
x: 123 x: 123
y: 456 y: 456
In little Bobby's kit's instructions booklet (provided as your puzzle input), what signal is In little Bobby's kit's instructions booklet (provided as your puzzle
ultimately provided to wire a? input), what signal is ultimately provided to wire a?
Your puzzle answer was 16076. Your puzzle answer was 16076.
--- Part Two --- --- Part Two ---
Now, take the signal you got on wire a, override wire b to that signal, and reset the other Now, take the signal you got on wire a, override wire b to that signal, and
wires (including wire a). What new signal is ultimately provided to wire a? reset the other wires (including wire a). What new signal is ultimately
provided to wire a?
Your puzzle answer was 2797. Your puzzle answer was 2797.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -98,6 +97,3 @@ References
. https://wiki.python.org/moin/BitwiseOperators . https://wiki.python.org/moin/BitwiseOperators
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/7/input . 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

View File

@ -1,68 +1,73 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 8: Matchsticks --- --- Day 8: Matchsticks ---
Space on the sleigh is limited this year, and so Santa will be bringing his list as a digital Space on the sleigh is limited this year, and so Santa will be bringing his
copy. He needs to know how much space it will take up when stored. 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 It is common in many programming languages to provide a way to escape
strings. For example, C, JavaScript, Perl, Python, and even PHP handle special characters in special characters in strings. For example, C, JavaScript, Perl, Python, and
very similar ways. 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 However, it is important to realize the difference between the number of
representation of the string literal and the number of characters in the in-memory string characters in the code representation of the string literal and the number
itself. of characters in the in-memory string itself.
For example: For example:
• "" is 2 characters of code (the two double quotes), but the string contains zero • "" is 2 characters of code (the two double quotes), but the string
characters. contains zero characters.
• "abc" is 5 characters of code, but 3 characters in the string data. • "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 • "aaa\"aaa" is 10 characters of code, but the string itself contains six
only escape sequences used are \\ (which represents a single backslash), \" (which represents a "a" characters and a single, escaped quote character, for a total of 7
lone double-quote character), and \x plus two hexadecimal characters (which represents a single characters in the string data.
character with that ASCII code).
Disregarding the whitespace in the file, what is the number of characters of code for string • "\x27" is 6 characters of code, but the string itself contains just one
literals minus the number of characters in memory for the values of the strings in total for - an apostrophe ('), escaped using hexadecimal notation.
the entire file?
For example, given the four strings above, the total number of characters of string code (2 + 5 Santa's list is a file that contains many double-quoted string literals, one
+ 10 + 6 = 23) minus the total number of characters in memory for string values (0 + 3 + 7 + 1 on each line. The only escape sequences used are \\ (which represents a
= 11) is 23 - 11 = 12. 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. Your puzzle answer was 1350.
--- Part Two --- --- Part Two ---
Now, let's go the other way. In addition to finding the number of characters of code, you Now, let's go the other way. In addition to finding the number of characters
should now encode each code representation as a new string and find the number of characters of of code, you should now encode each code representation as a new string and
the new encoded representation, including the surrounding double quotes. find the number of characters of the new encoded representation, including
the surrounding double quotes.
For example: For example:
• "" encodes to "\"\"", an increase from 2 characters to 6. • "" encodes to "\"\"", an increase from 2 characters to 6.
• "abc" encodes to "\"abc\"", an increase from 5 characters to 9. • "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. • "\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 Your task is to find the total number of characters to represent the newly
minus the number of characters of code in each original string literal. For example, for the encoded strings minus the number of characters of code in each original
strings above, the total encoded length (6 + 9 + 16 + 11 = 42) minus the characters in the string literal. For example, for the strings above, the total encoded length
original code representation (23, just like in the first part of this puzzle) is 42 - 23 = 19. (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. Your puzzle answer was 2085.
@ -72,8 +77,6 @@
If you still want to see it, you can get your puzzle input. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -90,6 +93,3 @@ References
. http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double . http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/8/input . 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

View File

@ -1,21 +1,14 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 9: All in a Single Night --- --- Day 9: All in a Single Night ---
Every year, Santa manages to deliver all of his presents 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 This year, however, he has some new locations to visit; his elves have
distances between every pair of locations. He can start and end at any two (different) provided him the distances between every pair of locations. He can start and
locations he wants, but he must visit each location exactly once. What is the shortest distance end at any two (different) locations he wants, but he must visit each
he can travel to achieve this? location exactly once. What is the shortest distance he can travel to
achieve this?
For example, given the following distances: For example, given the following distances:
@ -32,8 +25,8 @@
Belfast -> Dublin -> London = 605 Belfast -> Dublin -> London = 605
Belfast -> London -> Dublin = 982 Belfast -> London -> Dublin = 982
The shortest of these is London -> Dublin -> Belfast = 605, and so the answer is 605 in this The shortest of these is London -> Dublin -> Belfast = 605, and so the
example. answer is 605 in this example.
What is the distance of the shortest route? What is the distance of the shortest route?
@ -41,14 +34,14 @@
--- Part Two --- --- Part Two ---
The next year, just to show off, Santa decides to take the route with the longest distance The next year, just to show off, Santa decides to take the route with the
instead. longest distance instead.
He can still start and end at any two (different) locations he wants, and he still must visit He can still start and end at any two (different) locations he wants, and he
each location exactly once. still must visit each location exactly once.
For example, given the distances above, the longest route would be 982 via (for example) Dublin For example, given the distances above, the longest route would be 982 via
-> London -> Belfast. (for example) Dublin -> London -> Belfast.
What is the distance of the longest route? What is the distance of the longest route?
@ -56,12 +49,11 @@
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -73,6 +65,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/9/input . 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

View File

@ -1,22 +1,16 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 10: Elves Look, Elves Say --- --- Day 10: Elves Look, Elves Say ---
Today, the Elves are playing a game called look-and-say. They take turns making sequences by Today, the Elves are playing a game called look-and-say. They take turns
reading aloud the previous sequence and using that reading as the next sequence. For example, making sequences by reading aloud the previous sequence and using that
211 is read as "one two, two ones", which becomes 1221 (1 2, 2 1s). 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 Look-and-say sequences are generated iteratively, using the previous value
next step. For each step, take the previous value, and replace each run of digits (like 111) as input for the next step. For each step, take the previous value, and
with the number of digits (3) followed by the digit itself (1). replace each run of digits (like 111) with the number of digits (3) followed
by the digit itself (1).
For example: For example:
@ -26,18 +20,18 @@
 1211 becomes 111221 (one 1, one 2, and two 1s).  1211 becomes 111221 (one 1, one 2, and two 1s).
 111221 becomes 312211 (three 1s, two 2s, and one 1).  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 Starting with the digits in your puzzle input, apply this process 40 times.
of the result? What is the length of the result?
Your puzzle answer was 360154. Your puzzle answer was 360154.
--- Part Two --- --- Part Two ---
Neat, right? You might also enjoy hearing John Conway talking about this sequence (that's Neat, right? You might also enjoy hearing John Conway talking about this
Conway of Conway's Game of Life fame). 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 Now, starting again with the digits in your puzzle input, apply this process
the length of the new result? 50 times. What is the length of the new result?
Your puzzle answer was 5103798. Your puzzle answer was 5103798.
@ -47,8 +41,6 @@
Your puzzle input was 1113122113. Your puzzle input was 1113122113.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -61,6 +53,3 @@ References
. https://en.wikipedia.org/wiki/Look-and-say_sequence . https://en.wikipedia.org/wiki/Look-and-say_sequence
. https://www.youtube.com/watch?v=ea7lJkEhytA . https://www.youtube.com/watch?v=ea7lJkEhytA
. http://adventofcode.com/ . 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

View File

@ -1,48 +1,52 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 11: Corporate Policy --- --- Day 11: Corporate Policy ---
Santa's previous password expired, and he needs help choosing a new one. 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 To help him remember his new password after the old one expires, Santa has
coming up with a password based on the previous one. Corporate policy dictates that passwords devised a method of coming up with a password based on the previous one.
must be exactly eight lowercase letters (for security reasons), so he finds his new password by Corporate policy dictates that passwords must be exactly eight lowercase
incrementing his old password string repeatedly until it is valid. 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 Incrementing is just like counting with numbers: xx, xy, xz, ya, yb, and so
rightmost letter one step; if it was z, it wraps around to a, and repeat with the next letter on. Increase the rightmost letter one step; if it was z, it wraps around to
to the left until one doesn't wrap around. 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 Unfortunately for Santa, a new Security-Elf recently started, and he has
additional password requirements: imposed some additional password requirements:
 Passwords must include one increasing straight of at least three letters, like abc, bcd,  Passwords must include one increasing straight of at least three
cde, and so on, up to xyz. They cannot skip letters; abd doesn't count. letters, like abc, bcd, cde, and so on, up to xyz. They cannot skip
 Passwords may not contain the letters i, o, or l, as these letters can be mistaken for letters; abd doesn't count.
other characters and are therefore confusing.
 Passwords must contain at least two different, non-overlapping pairs of letters, like aa,  Passwords may not contain the letters i, o, or l, as these letters can
bb, or zz. 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: For example:
 hijklmmn meets the first requirement (because it contains the straight hij) but fails the  hijklmmn meets the first requirement (because it contains the straight
second requirement requirement (because it contains i and l). hij) but fails the second requirement requirement (because it contains i
 abbceffg meets the third requirement (because it repeats bb and ff) but fails the first and l).
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?  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. Your puzzle answer was hepxxyzz.
@ -54,12 +58,11 @@
Both parts of this puzzle are complete! They provide two gold stars: ** 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. Your puzzle input was hepxcrrq.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -70,6 +73,3 @@ References
. http://adventofcode.com/settings . http://adventofcode.com/settings
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . 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

View File

@ -1,27 +1,24 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 12: JSAbacusFramework.io --- --- Day 12: JSAbacusFramework.io ---
Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, Santa's Accounting-Elves need help balancing the books after a recent order.
their accounting software uses a peculiar storage format. That's where you come in. 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 They have a JSON document which contains a variety of things: arrays
({"a":1, "b":2}), numbers, and strings. Your first job is to simply find all of the numbers ([1,2,3]), objects ({"a":1, "b":2}), numbers, and strings. Your first job is
throughout the document and add them together. to simply find all of the numbers throughout the document and add them
together.
For example: For example:
• [1,2,3] and {"a":2,"b":4} both have a sum of 6. • [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. • [[[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. • {"a":[-1,1]} and [-1,{"a":1}] both have a sum of 0.
• [] and {} both have a sum of 0. • [] and {} both have a sum of 0.
You will not encounter any strings containing numbers. You will not encounter any strings containing numbers.
@ -32,27 +29,31 @@
--- Part Two --- --- 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 Ignore any object (and all of its children) which has any property with the
this only for objects ({...}), not arrays ([...]). value "red". Do this only for objects ({...}), not arrays ([...]).
• [1,2,3] still has a sum of 6. • [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. 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. • [1,"red",5] has a sum of 6, because "red" in an array has no effect.
Your puzzle answer was 87842. Your puzzle answer was 87842.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -65,6 +66,3 @@ References
. http://json.org/ . http://json.org/
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/12/input . 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

View File

@ -1,26 +1,20 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 13: Knights of the Dinner Table --- --- 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! In years past, the holiday feast with your family hasn't gone so well. Not
This year, you resolve, will be different. You're going to find the optimal seating arrangement everyone gets along! This year, you resolve, will be different. You're going
and avoid all those awkward conversations. 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 You start by writing up a list of everyone invited and the amount their
increase or decrease if they were to find themselves sitting next to each other person. You happiness would increase or decrease if they were to find themselves sitting
have a circular table that will be just big enough to fit everyone comfortably, and so each next to each other person. You have a circular table that will be just big
person will have exactly two neighbors. 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 For example, suppose you have only four attendees planned, and you calculate
happiness as follows: their potential happiness as follows:
Alice would gain 54 happiness units by sitting next to Bob. Alice would gain 54 happiness units by sitting next to Bob.
Alice would lose 79 happiness units by sitting next to Carol. 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 lose 7 happiness units by sitting next to Bob.
David would gain 41 happiness units by sitting next to Carol. 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 Then, if you seat Alice next to David, Alice would lose 2 happiness units
so much), but David would gain 46 happiness units (because Alice is such a good listener), for (because David talks so much), but David would gain 46 happiness units
a total change of 44. (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 If you continue around the table, you could then seat Bob next to Alice (Bob
gains 54). Finally, seat Carol, who sits next to Bob (Carol gains 60, Bob loses 7) and David gains 83, Alice gains 54). Finally, seat Carol, who sits next to Bob (Carol
(Carol gains 55, David gains 41). The arrangement looks like this: gains 60, Bob loses 7) and David (Carol gains 55, David gains 41). The
arrangement looks like this:
+41 +46 +41 +46
+55 David -2 +55 David -2
@ -49,37 +44,37 @@
+60 Bob +54 +60 Bob +54
-7 +83 -7 +83
After trying every other seating arrangement in this hypothetical scenario, you find that this After trying every other seating arrangement in this hypothetical scenario,
one is the most optimal, with a total change in happiness of 330. 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 What is the total change in happiness for the optimal seating arrangement of
list? the actual guest list?
Your puzzle answer was 733. Your puzzle answer was 733.
--- Part Two --- --- Part Two ---
In all the commotion, you realize that you forgot to seat yourself. At this point, you're In all the commotion, you realize that you forgot to seat yourself. At this
pretty apathetic toward the whole thing, and your happiness wouldn't really go up or down point, you're pretty apathetic toward the whole thing, and your happiness
regardless of who you sit next to. You assume everyone else would be just as ambivalent about wouldn't really go up or down regardless of who you sit next to. You assume
sitting next to you, too. 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 So, add yourself to the list, and give all happiness relationships that
0. involve you a score of 0.
What is the total change in happiness for the optimal seating arrangement that actually What is the total change in happiness for the optimal seating arrangement
includes yourself? that actually includes yourself?
Your puzzle answer was 725. Your puzzle answer was 725.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -91,6 +86,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/13/input . 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

View File

@ -1,62 +1,62 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 14: Reindeer Olympics --- --- Day 14: Reindeer Olympics ---
This year is the Reindeer Olympics! Reindeer can fly at high speeds, but must rest occasionally This year is the Reindeer Olympics! Reindeer can fly at high speeds, but
to recover their energy. Santa would like to know which of his reindeer is fastest, and so he must rest occasionally to recover their energy. Santa would like to know
has them race. 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), Reindeer can only either be flying (always at their top speed) or resting
and always spend whole seconds in either state. (not moving at all), and always spend whole seconds in either state.
For example, suppose you have the following Reindeer: For example, suppose you have the following Reindeer:
 Comet can fly 14 km/s for 10 seconds, but then must rest for 127 seconds.  Comet can fly 14 km/s for 10 seconds, but then must rest for 127
 Dancer can fly 16 km/s for 11 seconds, but then must rest for 162 seconds. seconds.
After one second, Comet has gone 14 km, while Dancer has gone 16 km. After ten seconds, Comet  Dancer can fly 16 km/s for 11 seconds, but then must rest for 162
has gone 140 km, while Dancer has gone 160 km. On the eleventh second, Comet begins resting seconds.
(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.
In this example, after the 1000th second, both reindeer are resting, and Comet is in the lead After one second, Comet has gone 14 km, while Dancer has gone 16 km. After
at 1120 km (poor Dancer has only gotten 1056 km by that point). So, in this situation, Comet ten seconds, Comet has gone 140 km, while Dancer has gone 160 km. On the
would win (if the race ended at 1000 seconds). 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, In this example, after the 1000th second, both reindeer are resting, and
what distance has the winning reindeer traveled? 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. Your puzzle answer was 2660.
--- Part Two --- --- 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. Instead, at the end of each second, he awards one point to the reindeer
(If there are multiple reindeer tied for the lead, they each get one point.) He keeps the currently in the lead. (If there are multiple reindeer tied for the lead,
traditional 2503 second time limit, of course, as doing otherwise would be entirely ridiculous. 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 Given the example reindeer from above, after the first second, Dancer is in
one point. He stays in the lead until several seconds into Comet's second burst: after the the lead and gets one point. He stays in the lead until several seconds into
140th second, Comet pulls into the lead and gets his first point. Of course, since Dancer had Comet's second burst: after the 140th second, Comet pulls into the lead and
been in the lead for the 139 seconds before that, he has accumulated 139 points by the 140th gets his first point. Of course, since Dancer had been in the lead for the
second. 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, After the 1000th second, Dancer has accumulated 689 points, while poor
only has 312. So, with the new scoring system, Dancer would win (if the race ended at 1000 Comet, our old champion, only has 312. So, with the new scoring system,
seconds). Dancer would win (if the race ended at 1000 seconds).
Again given the descriptions of each reindeer (in your puzzle input), after exactly 2503 Again given the descriptions of each reindeer (in your puzzle input), after
seconds, how many points does the winning reindeer have? exactly 2503 seconds, how many points does the winning reindeer have?
Your puzzle answer was 1256. Your puzzle answer was 1256.
@ -66,8 +66,6 @@
If you still want to see it, you can get your puzzle input. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -79,6 +77,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/14/input . 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

View File

@ -1,81 +1,81 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 15: Science for Hungry People --- --- Day 15: Science for Hungry People ---
Today, you set out on the task of perfecting your milk-dunking cookie recipe. All you have to Today, you set out on the task of perfecting your milk-dunking cookie
do is find the right balance of ingredients. 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 Your recipe leaves room for exactly 100 teaspoons of ingredients. You make a
remaining ingredients you could use to finish the recipe (your puzzle input) and their list of the remaining ingredients you could use to finish the recipe (your
properties per teaspoon: puzzle input) and their properties per teaspoon:
 capacity (how well it helps the cookie absorb milk)  capacity (how well it helps the cookie absorb milk)
 durability (how well it keeps the cookie intact when full of milk)  durability (how well it keeps the cookie intact when full of milk)
 flavor (how tasty it makes the cookie)  flavor (how tasty it makes the cookie)
 texture (how it improves the feel of the cookie)  texture (how it improves the feel of the cookie)
 calories (how many calories it adds to 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 You can only measure ingredients in whole-teaspoon amounts accurately, and
accurate so you can reproduce your results in the future. The total score of a cookie can be you have to be accurate so you can reproduce your results in the future. The
found by adding up each of the properties (negative totals become 0) and then multiplying total score of a cookie can be found by adding up each of the properties
together everything except calories. (negative totals become 0) and then multiplying together everything except
calories.
For instance, suppose you have these two ingredients: For instance, suppose you have these two ingredients:
Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8 Butterscotch: capacity -1, durability -2, flavor 6, texture 3, calories 8
Cinnamon: capacity 2, durability 3, flavor -2, texture -1, calories 3 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 Then, choosing to use 44 teaspoons of butterscotch and 56 teaspoons of
amounts of each ingredient must add up to 100) would result in a cookie with the following cinnamon (because the amounts of each ingredient must add up to 100) would
properties: result in a cookie with the following properties:
 A capacity of 44*-1 + 56*2 = 68  A capacity of 44*-1 + 56*2 = 68
 A durability of 44*-2 + 56*3 = 80  A durability of 44*-2 + 56*3 = 80
 A flavor of 44*6 + 56*-2 = 152  A flavor of 44*6 + 56*-2 = 152
 A texture of 44*3 + 56*-1 = 76  A texture of 44*3 + 56*-1 = 76
Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now) results in a total Multiplying these together (68 * 80 * 152 * 76, ignoring calories for now)
score of 62842880, which happens to be the best score possible given these ingredients. If any results in a total score of 62842880, which happens to be the best score
properties had produced a negative total, it would have instead become zero, causing the whole possible given these ingredients. If any properties had produced a negative
score to multiply to zero. 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 Given the ingredients in your kitchen and their properties, what is the
highest-scoring cookie you can make? total score of the highest-scoring cookie you can make?
Your puzzle answer was 18965440. Your puzzle answer was 18965440.
--- Part Two --- --- Part Two ---
Your cookie recipe becomes wildly popular! Someone asks if you can make another recipe that has Your cookie recipe becomes wildly popular! Someone asks if you can make
exactly 500 calories per cookie (so they can use it as a meal replacement). Keep the rest of another recipe that has exactly 500 calories per cookie (so they can use it
your award-winning process the same (100 teaspoons, same ingredients, same scoring system). 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 For example, given the ingredients above, if you had instead selected 40
butterscotch and 60 teaspoons of cinnamon (which still adds to 100), the total calorie count teaspoons of butterscotch and 60 teaspoons of cinnamon (which still adds to
would be 40*8 + 60*3 = 500. The total score would go down, though: only 57600000, the best you 100), the total calorie count would be 40*8 + 60*3 = 500. The total score
can do in such trying circumstances. 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 Given the ingredients in your kitchen and their properties, what is the
highest-scoring cookie you can make with a calorie total of 500? total score of the highest-scoring cookie you can make with a calorie total
of 500?
Your puzzle answer was 15862900. Your puzzle answer was 15862900.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -87,6 +87,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/15/input . 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

View File

@ -1,39 +1,42 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 16: Aunt Sue --- --- Day 16: Aunt Sue ---
Your Aunt Sue has given you a wonderful gift, and you'd like to send her a thank you card. Your Aunt Sue has given you a wonderful gift, and you'd like to send her a
However, there's a small problem: she signed it "From, Aunt Sue". thank you card. However, there's a small problem: she signed it "From, Aunt
Sue".
You have 500 Aunts named "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 So, to avoid sending the card to the wrong person, you need to figure out
you conveniently number 1 to 500, for sanity) gave you the gift. You open the present and, as which Aunt Sue (which you conveniently number 1 to 500, for sanity) gave you
luck would have it, good ol' Aunt Sue got you a My First Crime Scene Analysis Machine! Just the gift. You open the present and, as luck would have it, good ol' Aunt Sue
what you wanted. Or needed, as the case may be. 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 The My First Crime Scene Analysis Machine (MFCSAM for short) can detect a
compounds in a given sample, as well as how many distinct kinds of those compounds there are. few specific compounds in a given sample, as well as how many distinct kinds
According to the instructions, these are what the MFCSAM can detect: of those compounds there are. According to the instructions, these are what
the MFCSAM can detect:
 children, by human DNA age analysis.  children, by human DNA age analysis.
 cats. It doesn't differentiate individual breeds.  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.  goldfish. No other kinds of fish.
 trees, all in one group.  trees, all in one group.
 cars, presumably by exhaust or gasoline or something.  cars, presumably by exhaust or gasoline or something.
 perfumes, which is handy, since many of your Aunts Sue wear a few kinds.  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 In fact, many of your Aunts Sue have many of these. You put the wrapping
MFCSAM. It beeps inquisitively at you a few times and then prints out a message on ticker tape: 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 children: 3
cats: 7 cats: 7
@ -46,8 +49,8 @@
cars: 2 cars: 2
perfumes: 1 perfumes: 1
You make a list of the things you can remember about each Aunt Sue. Things missing from your You make a list of the things you can remember about each Aunt Sue. Things
list aren't zero - you simply don't remember the value. 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? What is the number of the Sue that got you the gift?
@ -55,14 +58,16 @@
--- Part Two --- --- Part Two ---
As you're about to send the thank you note, something in the MFCSAM's instructions catches your As you're about to send the thank you note, something in the MFCSAM's
eye. Apparently, it has an outdated retroencabulator, and so the output from the machine isn't instructions catches your eye. Apparently, it has an outdated
exact values - some of them indicate ranges. 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 In particular, the cats and trees readings indicates that there are greater
to the unpredictable nuclear decay of cat dander and tree pollen), while the pomeranians and than that many (due to the unpredictable nuclear decay of cat dander and
goldfish readings indicate that there are fewer than that many (due to the modial interaction tree pollen), while the pomeranians and goldfish readings indicate that
of magnetoreluctance). there are fewer than that many (due to the modial interaction of
magnetoreluctance).
What is the number of the real Aunt Sue? 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: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -93,6 +97,3 @@ References
. https://www.youtube.com/watch?v=RXJKdh1KZ0w . https://www.youtube.com/watch?v=RXJKdh1KZ0w
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/16/input . 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

View File

@ -1,53 +1,46 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 17: No Such Thing as Too Much --- --- 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 The elves bought too much eggnog again - 150 liters this time. To fit it all
refrigerator, you'll need to move it into smaller containers. You take an inventory of the into your refrigerator, you'll need to move it into smaller containers. You
capacities of the available containers. 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 For example, suppose you have containers of size 20, 15, 10, 5, and 5
store 25 liters, there are four ways to do it: liters. If you need to store 25 liters, there are four ways to do it:
 15 and 10  15 and 10
 20 and 5 (the first 5)  20 and 5 (the first 5)
 20 and 5 (the second 5)  20 and 5 (the second 5)
 15, 5, and 5  15, 5, and 5
Filling all containers entirely, how many different combinations of containers can exactly fit Filling all containers entirely, how many different combinations of
all 150 liters of eggnog? containers can exactly fit all 150 liters of eggnog?
Your puzzle answer was 1304. Your puzzle answer was 1304.
--- Part Two --- --- Part Two ---
While playing with all the containers in the kitchen, another load of eggnog arrives! The While playing with all the containers in the kitchen, another load of eggnog
shipping and receiving department is requesting as many containers as you can spare. 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 Find the minimum number of containers that can exactly fit all 150 liters of
different ways can you fill that number of containers and still hold exactly 150 litres? 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 In the example above, the minimum number of containers was two. There were
that many containers, and so the answer there would be 3. three ways to use that many containers, and so the answer there would be 3.
Your puzzle answer was 18. Your puzzle answer was 18.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -59,6 +52,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/17/input . 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

View File

@ -1,31 +1,27 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 18: Like a GIF For Your Yard --- --- Day 18: Like a GIF For Your Yard ---
After the million lights incident, the fire code has gotten stricter: now, at most ten thousand After the million lights incident, the fire code has gotten stricter: now,
lights are allowed. You arrange them in a 100x100 grid. 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 Never one to let you down, Santa again mails you instructions on the ideal
configuration. With so few lights, he says, you'll have to resort to animation. 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 # Start by setting your lights to the included initial configuration (your
means "on", and a . means "off". 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 Then, animate your grid in steps, where each step decides the next
current one. Each light's next state (either on or off) depends on its current state and the configuration based on the current one. Each light's next state (either on
current states of the eight lights adjacent to it (including diagonals). Lights on the edge of or off) depends on its current state and the current states of the eight
the grid might have fewer than eight neighbors; the missing ones always count as "off". 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 For example, in a simplified 6x6 grid, the light marked A has the neighbors
8, and the light marked B, which is on an edge, only has the neighbors marked 1 through 5: numbered 1 through 8, and the light marked B, which is on an edge, only has
the neighbors marked 1 through 5:
1B5... 1B5...
234... 234...
@ -34,14 +30,17 @@
..8A4. ..8A4.
..765. ..765.
The state a light should have next is based on its current state (on or off) plus the number of The state a light should have next is based on its current state (on or off)
neighbors that are on: 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 on stays on when 2 or 3 neighbors are on, and turns off
 A light which is off turns on if exactly 3 neighbors are on, and stays off otherwise. otherwise.
All of the lights update simultaneously; they all consider the same current state before moving  A light which is off turns on if exactly 3 neighbors are on, and stays
to the next. 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: 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. 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 In your grid of 100x100 lights, given your initial configuration, how many
100 steps? lights are on after 100 steps?
Your puzzle answer was 814. Your puzzle answer was 814.
--- Part Two --- --- Part Two ---
You flip the instructions over; Santa goes on to point out that this is all just an You flip the instructions over; Santa goes on to point out that this is all
implementation of Conway's Game of Life. At least, it was, until you notice that something's just an implementation of Conway's Game of Life. At least, it was, until you
wrong with the grid of lights you bought: four lights, one in each corner, are stuck on and notice that something's wrong with the grid of lights you bought: four
can't be turned off. The example above will actually run like this: lights, one in each corner, are stuck on and can't be turned off. The
example above will actually run like this:
Initial state: Initial state:
##.#.# ##.#.#
@ -149,19 +149,19 @@
After 5 steps, this example now has 17 lights on. 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 In your grid of 100x100 lights, given your initial configuration, but with
always in the on state, how many lights are on after 100 steps? the four corners always in the on state, how many lights are on after 100
steps?
Your puzzle answer was 924. Your puzzle answer was 924.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -175,6 +175,3 @@ References
. https://en.wikipedia.org/wiki/Conway's_Game_of_Life . https://en.wikipedia.org/wiki/Conway's_Game_of_Life
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/18/input . 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

View File

@ -1,38 +1,32 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 19: Medicine for Rudolph --- --- Day 19: Medicine for Rudolph ---
Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very brightly, and he needs Rudolph the Red-Nosed Reindeer is sick! His nose isn't shining very
medicine. brightly, and he needs medicine.
Red-Nosed Reindeer biology isn't similar to regular reindeer biology; Rudolph is going to need Red-Nosed Reindeer biology isn't similar to regular reindeer biology;
custom-made medicine. Unfortunately, Red-Nosed Reindeer chemistry isn't similar to regular Rudolph is going to need custom-made medicine. Unfortunately, Red-Nosed
reindeer chemistry, either. 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 The North Pole is equipped with a Red-Nosed Reindeer nuclear fusion/fission
constructing any Red-Nosed Reindeer molecule you need. It works by starting with some input plant, capable of constructing any Red-Nosed Reindeer molecule you need. It
molecule and then doing a series of replacements, one per step, until it has the right works by starting with some input molecule and then doing a series of
molecule. replacements, one per step, until it has the right molecule.
However, the machine has to be calibrated before it can be used. Calibration involves However, the machine has to be calibrated before it can be used. Calibration
determining the number of molecules that can be generated in one step from a given starting involves determining the number of molecules that can be generated in one
point. 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 => HO
H => OH H => OH
O => HH 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).  HOOH (via H => HO on the first H).
 HOHO (via H => HO on the second H).  HOHO (via H => HO on the second H).
@ -40,25 +34,28 @@
 HOOH (via H => OH on the second H).  HOOH (via H => OH on the second H).
 HHHH (via O => HH).  HHHH (via O => HH).
So, in the example above, there are 4 distinct molecules (not five, because HOOH appears twice) So, in the example above, there are 4 distinct molecules (not five, because
after one replacement from HOH. Santa's favorite molecule, HOHOHO, can become 7 distinct HOOH appears twice) after one replacement from HOH. Santa's favorite
molecules (over nine replacements: six from H, and three from O). 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 The machine replaces without regard for the surrounding characters. For
string H2O, the transition H => OO would result in OO2O. 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 Your puzzle input describes all of the possible replacements and, at the
molecule for which you need to calibrate the machine. How many distinct molecules can be bottom, the medicine molecule for which you need to calibrate the machine.
created after all the different ways you can do one replacement on the medicine molecule? 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. Your puzzle answer was 518.
--- Part Two --- --- 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 Molecule fabrication always begins with just a single electron, e, and
one at a time, just like the ones during calibration. applying replacements one at a time, just like the ones during calibration.
For example, suppose you have the following replacements: For example, suppose you have the following replacements:
@ -68,29 +65,29 @@
H => OH H => OH
O => HH 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  e => O to get O
 O => HH to get HH  O => HH to get HH
 H => OH (on the second H) to get HOH  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 So, you could make HOH after 3 steps. Santa's favorite molecule, HOHOHO, can
steps. be made in 6 steps.
How long will it take to make the medicine? Given the available replacements and the medicine How long will it take to make the medicine? Given the available replacements
molecule in your puzzle input, what is the fewest number of steps to go from e to the medicine and the medicine molecule in your puzzle input, what is the fewest number of
molecule? steps to go from e to the medicine molecule?
Your puzzle answer was 200. Your puzzle answer was 200.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -102,6 +99,3 @@ References
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/19/input . 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

View File

@ -1,26 +1,25 @@
Advent of Code Advent of Code
br0xen 40*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 20: Infinite Elves and Infinite Houses --- --- 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 To keep the Elves busy, Santa has them deliver some presents by hand,
them down a street with infinite houses numbered sequentially: 1, 2, 3, 4, 5, and so on. 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 first Elf (number 1) delivers presents to every house: 1, 2, 3, 4,
 The second Elf (number 2) delivers presents to every second house: 2, 4, 6, 8, 10, .... 5, ....
 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  The second Elf (number 2) delivers presents to every second house: 2, 4,
ten times his or her number at each house. 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: So, the first nine houses on the street end up like this:
@ -34,34 +33,34 @@
House 8 got 150 presents. House 8 got 150 presents.
House 9 got 130 presents. House 9 got 130 presents.
The first house gets 10 presents: it is visited only by Elf 1, which delivers 1 * 10 = 10 The first house gets 10 presents: it is visited only by Elf 1, which
presents. The fourth house gets 70 presents, because it is visited by Elves 1, 2, and 4, for a delivers 1 * 10 = 10 presents. The fourth house gets 70 presents, because it
total of 10 + 20 + 40 = 70 presents. 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 What is the lowest house number of the house to get at least as many
your puzzle input? presents as the number in your puzzle input?
Your puzzle answer was 831600. Your puzzle answer was 831600.
--- Part Two --- --- Part Two ---
The Elves decide they don't want to visit an infinite number of houses. Instead, each Elf will The Elves decide they don't want to visit an infinite number of houses.
stop after delivering presents to 50 houses. To make up for it, they decide to deliver presents Instead, each Elf will stop after delivering presents to 50 houses. To make
equal to eleven times their number at each house. 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 With these changes, what is the new lowest house number of the house to get
presents as the number in your puzzle input? at least as many presents as the number in your puzzle input?
Your puzzle answer was 884520. Your puzzle answer was 884520.
Both parts of this puzzle are complete! They provide two gold stars: ** 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. Your puzzle input was 36000000.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -72,6 +71,3 @@ References
. http://adventofcode.com/settings . http://adventofcode.com/settings
. http://adventofcode.com/auth/logout . http://adventofcode.com/auth/logout
. http://adventofcode.com/ . 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

View File

@ -10,22 +10,25 @@
--- Day 21: RPG Simulator 20XX --- --- 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. Little Henry Case got a new video game for Christmas. It's an RPG, and he's
He needs to know what equipment to buy at the shop. He hands you the controller. 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 In this game, the player (you) and the enemy (the boss) take turns
always goes first. Each attack reduces the opponent's hit points by at least 1. The first attacking. The player always goes first. Each attack reduces the opponent's
character at or below 0 hit points loses. 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 Damage dealt by an attacker each turn is equal to the attacker's damage
defender's armor score. An attacker always does at least 1 damage. So, if the attacker has a score minus the defender's armor score. An attacker always does at least 1
damage score of 8, and the defender has an armor score of 3, the defender loses 5 hit points. damage. So, if the attacker has a damage score of 8, and the defender has an
If the defender had an armor score of 300, the defender would still lose 1 hit point. 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 Your damage score and armor score both start at zero. They can be increased
exchange for gold. You start with no items and have as much gold as you need. Your total by buying items in exchange for gold. You start with no items and have as
damage or armor is equal to the sum of those stats from all of your items. You have 100 hit much gold as you need. Your total damage or armor is equal to the sum of
points. those stats from all of your items. You have 100 hit points.
Here is what the item shop is selling: Here is what the item shop is selling:
@ -51,12 +54,13 @@
Defense +2 40 0 2 Defense +2 40 0 2
Defense +3 80 0 3 Defense +3 80 0 3
You must buy exactly one weapon; no dual-wielding. Armor is optional, but you can't use more You must buy exactly one weapon; no dual-wielding. Armor is optional, but
than one. You can buy 0-2 rings (at most one for each hand). You must use any items you buy. you can't use more than one. You can buy 0-2 rings (at most one for each
The shop only has one of each item, so you can't buy, for example, two rings of Damage +3. 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 For example, suppose you have 8 hit points, 5 damage, and 5 armor, and that
hit points, 7 damage, and 2 armor: 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 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.  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.) 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 You have 100 hit points. The boss's actual stats are in your puzzle input.
amount of gold you can spend and still win the fight? What is the least amount of gold you can spend and still win the fight?
Your puzzle answer was 91. Your puzzle answer was 91.
--- Part Two --- --- Part Two ---
Turns out the shopkeeper is working with the boss, and can persuade you to buy whatever items Turns out the shopkeeper is working with the boss, and can persuade you to
he wants. The other rules still apply, and he still only has one of each item. 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? 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: ** 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. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -103,6 +107,3 @@ References
. https://en.wikipedia.org/wiki/Game_controller . https://en.wikipedia.org/wiki/Game_controller
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/21/input . 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

View File

@ -1,50 +1,52 @@
Advent of Code Advent of Code
br0xen 44*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 22: Wizard Simulator 20XX --- --- Day 22: Wizard Simulator 20XX ---
Little Henry Case decides that defeating bosses with swords and stuff is boring. Now he's Little Henry Case decides that defeating bosses with swords and stuff is
playing the game with a wizard. Of course, he gets stuck on another boss and needs your help boring. Now he's playing the game with a wizard. Of course, he gets stuck on
again. another boss and needs your help again.
In this version, combat still proceeds with the player and the boss taking alternating turns. In this version, combat still proceeds with the player and the boss taking
The player still goes first. Now, however, you don't get any equipment; instead, you must alternating turns. The player still goes first. Now, however, you don't get
choose one of your spells to cast. The first character at or below 0 hit points loses. 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're a wizard, you don't get to wear armor, and you can't attack
since you do magic damage, your opponent's armor is ignored, and so the boss effectively has normally. However, since you do magic damage, your opponent's armor is
zero armor as well. As before, if armor (from a spell, in this case) would reduce damage below ignored, and so the boss effectively has zero armor as well. As before, if
1, it becomes 1 instead - that is, the boss' attacks always deal at least 1 damage. 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 On each of your turns, you must select one of your spells to cast. If you
cast any spell, you lose. Spells cost mana; you start with 500 mana, but have no maximum cannot afford to cast any spell, you lose. Spells cost mana; you start with
limit. You must have enough mana to cast a spell, and its cost is immediately deducted when 500 mana, but have no maximum limit. You must have enough mana to cast a
you cast it. Your spells are Magic Missile, Drain, Shield, Poison, and Recharge. 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.  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  Drain costs 73 mana. It instantly does 2 damage and heals you for 2 hit
boss' turns. Effects are created with a timer (the number of turns they last); at the start of points.
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  Shield costs 113 mana. It starts an effect that lasts for 6 turns. While
points and 8 damage: 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 turn --
- Player has 10 hit points, 0 armor, 250 mana - Player has 10 hit points, 0 armor, 250 mana
@ -68,7 +70,8 @@
- Boss has 3 hit points - Boss has 3 hit points
Poison deals 3 damage. This kills the boss, and the player wins. 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 turn --
- Player has 10 hit points, 0 armor, 250 mana - Player has 10 hit points, 0 armor, 250 mana
@ -135,27 +138,45 @@
- Boss has 2 hit points - Boss has 2 hit points
Poison deals 3 damage. This kills the boss, and the player wins. 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 You start with 50 hit points and 500 mana points. The boss's actual stats
input. What is the least amount of mana you can spend and still win the fight? (Do not include are in your puzzle input. What is the least amount of mana you can spend and
mana recharge effects as "spending" negative mana.) 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 References
Visible links Visible links
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/about . http://adventofcode.com/2015/about
. http://adventofcode.com/stats . http://adventofcode.com/2015/support
. http://adventofcode.com/leaderboard . http://adventofcode.com/2015/events
. http://adventofcode.com/settings . http://adventofcode.com/2015/settings
. http://adventofcode.com/auth/logout . http://adventofcode.com/2015/auth/logout
. http://adventofcode.com/day/21 . http://adventofcode.com/2015
. http://adventofcode.com/day/22/input . http://adventofcode.com/2015
. 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 . http://adventofcode.com/2015/leaderboard
. https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F22 . http://adventofcode.com/2015/stats
. 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/sponsors
. http://adventofcode.com/2015/day/21
. http://adventofcode.com/2015
. http://adventofcode.com/2015/day/22/input

View File

@ -1,48 +1,54 @@
Advent of Code Advent of Code
br0xen 43*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 23: Opening the Turing Lock --- --- Day 23: Opening the Turing Lock ---
Little Jane Marie just got her very first computer for Christmas from some unknown benefactor. Little Jane Marie just got her very first computer for Christmas from some
It comes with instructions and an example program, but the computer itself seems to be unknown benefactor. It comes with instructions and an example program, but
malfunctioning. She's curious what the program does, and would like you to help her run it. 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 The manual explains that the computer supports two registers and six
goes on to remind the reader, a state-of-the-art technology). The registers are named a and b, instructions (truly, it goes on to remind the reader, a state-of-the-art
can hold any non-negative integer, and begin with a value of 0. The instructions are as technology). The registers are named a and b, can hold any non-negative
follows: 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.  hlf r sets register r to half its current value, then continues with the
 tpl r sets register r to triple its current value, then continues with the next next instruction.
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).
All three jump instructions work with an offset relative to that instruction. The offset is  tpl r sets register r to triple its current value, then continues with
always written with a prefix + or - to indicate the direction of the jump (forward or the next instruction.
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.  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  jmp offset is a jump; it continues with the instruction offset away
instruction: 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 inc a
jio a, +2 jio a, +2
tpl a tpl a
inc 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. Your puzzle answer was 255.
@ -50,15 +56,14 @@
--- Part Two --- --- Part Two ---
The unknown benefactor is very thankful for releasi-- er, helping little Jane Marie with her The unknown benefactor is very thankful for releasi-- er, helping little
computer. Definitely not to distract you, what is the value in register b after the program is Jane Marie with her computer. Definitely not to distract you, what is the
finished executing if register a starts as 1 instead? 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. Although it hasn't changed, you can still get your puzzle input.
Answer: _____________________ [ [Submit] ] Answer: 334
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
@ -73,6 +78,3 @@ References
. https://en.wikipedia.org/wiki/Instruction_set . https://en.wikipedia.org/wiki/Instruction_set
. https://en.wikipedia.org/wiki/Natural_number . https://en.wikipedia.org/wiki/Natural_number
. http://adventofcode.com/day/23/input . 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

View File

@ -1,42 +1,39 @@
Advent of Code Advent of Code
br0xen 50*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 24: It Hangs in the Balance --- --- Day 24: It Hangs in the Balance ---
It's Christmas Eve, and Santa is loading up the sleigh for this year's deliveries. However, It's Christmas Eve, and Santa is loading up the sleigh for this year's
there's one small problem: he can't get the sleigh to balance. If it isn't balanced, he can't deliveries. However, there's one small problem: he can't get the sleigh to
defy physics, and nobody gets presents this year. balance. If it isn't balanced, he can't defy physics, and nobody gets
presents this year.
No pressure. No pressure.
Santa has provided you a list of the weights of every package he needs to fit on the sleigh. Santa has provided you a list of the weights of every package he needs to
The packages need to be split into three groups of exactly the same weight, and every package fit on the sleigh. The packages need to be split into three groups of
has to fit. The first group goes in the passenger compartment of the sleigh, and the second exactly the same weight, and every package has to fit. The first group goes
and third go in containers on either side. Only when all three groups weigh exactly the same 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! 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 Of course, that's not the only problem. The first group - the one going in
compartment - needs as few packages as possible so that Santa has some legroom left over. It the passenger compartment - needs as few packages as possible so that Santa
doesn't matter how many packages are in either of the other two groups, so long as all of the has some legroom left over. It doesn't matter how many packages are in
groups weigh the same. 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 Furthermore, Santa tells you, if there are multiple ways to arrange the
fewest possible are in the first group, you need to choose the way where the first group has packages such that the fewest possible are in the first group, you need to
the smallest quantum entanglement to reduce the chance of any "complications". The quantum choose the way where the first group has the smallest quantum entanglement
entanglement of a group of packages is the product of their weights, that is, the value you to reduce the chance of any "complications". The quantum entanglement of a
get when you multiply their weights together. Only consider quantum entanglement if the first group of packages is the product of their weights, that is, the value you
group has the fewest possible number of packages in it and all groups weigh the same amount. 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 For example, suppose you have ten packages with weights 1 through 5 and 7
situation, some of the unique first groups, their quantum entanglements, and a way to divide through 11. For this situation, some of the unique first groups, their
the remaining packages are as follows: quantum entanglements, and a way to divide the remaining packages are as
follows:
Group 1; Group 2; Group 3 Group 1; Group 2; Group 3
11 9 (QE= 99); 10 8 2; 7 5 4 3 1 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 8 5 4 3 (QE=480); 11 9; 10 7 2 1
7 5 4 3 1 (QE=420); 11 9; 10 8 2 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 Of these, although 10 9 1 has the smallest quantum entanglement (90), the
only two packages, 11 9, in the passenger compartment gives Santa the most legroom and wins. configuration with only two packages, 11 9, in the passenger compartment
In this situation, the quantum entanglement for the ideal configuration is therefore 99. Had gives Santa the most legroom and wins. In this situation, the quantum
there been two configurations with only two packages in the first group, the one with the 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. 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. Your puzzle answer was 10439961859.
@ -69,11 +68,12 @@
"Ho ho ho", Santa muses to himself. "I forgot the trunk". "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 Balance the sleigh again, but this time, separate the packages into four
three. The other constraints still apply. 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 Given the example packages above, this would be some of the new unique first
quantum entanglements, and one way to divide the remaining packages: groups, their quantum entanglements, and one way to divide the remaining
packages:
11 4 (QE=44); 10 5; 9 3 2 1; 8 7 11 4 (QE=44); 10 5; 9 3 2 1; 8 7
10 5 (QE=50); 11 4; 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 9 3 2 1 (QE=54); 11 4; 10 5; 8 7
8 7 (QE=56); 11 4; 10 5; 9 3 2 1 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 Of these, there are three arrangements that put the minimum (two) number of
first group: 11 4, 10 5, and 8 7. Of these, 11 4 has the lowest quantum entanglement, and so packages in the first group: 11 4, 10 5, and 8 7. Of these, 11 4 has the
it is selected. lowest quantum entanglement, and so it is selected.
Now, what is the quantum entanglement of the first group of packages in the ideal Now, what is the quantum entanglement of the first group of packages in the
configuration? ideal configuration?
Your puzzle answer was 72050269. Your puzzle answer was 72050269.
@ -97,8 +97,6 @@
If you still want to see it, you can get your puzzle input. If you still want to see it, you can get your puzzle input.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -111,6 +109,3 @@ References
. https://en.wikipedia.org/wiki/Product_%28mathematics%29 . https://en.wikipedia.org/wiki/Product_%28mathematics%29
. http://adventofcode.com/ . http://adventofcode.com/
. http://adventofcode.com/day/24/input . 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

View File

@ -1,38 +1,33 @@
Advent of Code Advent of Code
br0xen 46*
• [About]
• [Stats]
• [Leaderboard]
• [Settings]
• [Log out]
--- Day 25: Let It Snow --- --- Day 25: Let It Snow ---
Merry Christmas! Santa is booting up his weather machine; looks like you might get a white Merry Christmas! Santa is booting up his weather machine; looks like you
Christmas after all. might get a white Christmas after all.
The weather machine beeps! On the console of the machine is a copy protection message asking The weather machine beeps! On the console of the machine is a copy
you to enter a code from the instruction manual. Apparently, it refuses to run unless you give protection message asking you to enter a code from the instruction manual.
it that code. No problem; you'll just look up the code in the-- 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." "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 - You look up the support number for the manufacturer and give them a call.
that 49th star wasn't going to earn itself. 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 "Oh, that machine is quite old!", they tell you. "That model went out of
ago, and we just finished shredding all of the manuals. I bet we can find you the code support six minutes ago, and we just finished shredding all of the manuals.
generation algorithm, though." 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 After putting you on hold for twenty minutes (your call is very important to
you repeatedly), they finally find an engineer that remembers how the code system works. 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 The codes are printed on an infinite sheet of paper, starting in the
codes are filled in by diagonals: starting with the first row with an empty first box, the top-left corner. The codes are filled in by diagonals: starting with the
codes are filled in diagonally up and to the right. This process repeats until the infinite first row with an empty first box, the codes are filled in diagonally up and
paper is covered. So, the first few codes are filled in in this order: 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 | 1 2 3 4 5 6
---+---+---+---+---+---+---+ ---+---+---+---+---+---+---+
@ -43,19 +38,21 @@
5 | 11 17 5 | 11 17
6 | 16 6 | 16
For example, the 12th code would be written to row 4, column 2; the 15th code would be written For example, the 12th code would be written to row 4, column 2; the 15th
to row 1, column 5. 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 voice on the other end of the phone continues with how the codes are
The first code is 20151125. After that, each code is generated by taking the previous one, actually generated. The first code is 20151125. After that, each code is
multiplying it by 252533, and then keeping the remainder from dividing that value by 33554393. 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, So, to find the second code (which ends up in row 2, column 1), start with
20151125. Multiply it by 252533 to get 5088824049625. Then, divide that by 33554393, which the previous value, 20151125. Multiply it by 252533 to get 5088824049625.
leaves a remainder of 31916031. That remainder is the second code. 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 "Oh!", says the voice. "It looks like we missed a scrap from one of the
it to you." You write down his numbers: manuals. Let me read it to you." You write down his numbers:
| 1 2 3 4 5 6 | 1 2 3 4 5 6
---+---------+---------+---------+---------+---------+---------+ ---+---------+---------+---------+---------+---------+---------+
@ -66,12 +63,13 @@
5 | 77061 17552253 28094349 6899651 9250759 31663883 5 | 77061 17552253 28094349 6899651 9250759 31663883
6 | 33071741 6796745 25397450 24659492 1534922 27995004 6 | 33071741 6796745 25397450 24659492 1534922 27995004
"Now remember", the voice continues, "that's not even all of the first few numbers; for "Now remember", the voice continues, "that's not even all of the first few
example, you're missing the one at 7,1 that would come before 6,2. But, it should be enough to numbers; for example, you're missing the one at 7,1 that would come before
let your-- oh, it's time for lunch! Bye!" The call disconnects. 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 Santa looks nervous. Your puzzle input contains the message on the machine's
code do you give the machine? console. What code do you give the machine?
Your puzzle answer was 19980801. Your puzzle answer was 19980801.
@ -79,16 +77,16 @@
--- Part Two --- --- Part Two ---
The machine springs to life, then falls silent again. It beeps. "Insufficient fuel", the The machine springs to life, then falls silent again. It beeps.
console reads. "Fifty stars are required before proceeding. One star is available." "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 ..."one star is available"? You check the fuel tank; sure enough, a lone
bottom, awaiting its friends. Looks like you need to provide 49 yourself. 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 don't have enough stars to start the machine, though. You need x more.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References
Visible links Visible links
@ -101,6 +99,3 @@ References
. http://adventofcode.com/day/1 . http://adventofcode.com/day/1
. https://en.wikipedia.org/wiki/Copy_protection#Early_video_games . https://en.wikipedia.org/wiki/Copy_protection#Early_video_games
. https://en.wikipedia.org/wiki/Cantor's_diagonal_argument . 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

View File

@ -2,38 +2,55 @@ Advent of Code
--- Day 1: No Time for a Taxicab --- --- 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. 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 You're airdropped near Easter Bunny Headquarters in a city somewhere.
to work them out further. "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. 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: For example:
 Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away.  Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5
 R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away. 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.  R5, L5, R5, R3 leaves you 12 blocks away.
How many blocks away is Easter Bunny HQ? How many blocks away is Easter Bunny HQ?
Your puzzle answer was ___. Your puzzle answer was 243.
--- Part Two --- --- 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? 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. If you still want to see it, you can get your puzzle input.

View File

@ -2,20 +2,24 @@ Advent of Code
--- Day 2: Bathroom Security --- --- 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 You arrive at Easter Bunny Headquarters under cover of darkness. However,
use the bathroom! Fancy office buildings like this one usually have keypad locks on their bathrooms, so you search the you left in such a rush that you forgot to use the bathroom! Fancy office
front desk for the code. 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, "In order to improve security," the document you find says, "bathroom codes
please memorize and follow the procedure below to access the bathrooms." 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 The document goes on to explain that each button to be pressed can be found
moving to adjacent buttons on the keypad: U moves up, D moves down, L moves left, and R moves right. Each line of by starting on the previous button and moving to adjacent buttons on the
instructions corresponds to one button, starting at the previous button (or, for the first line, the "5" button); press keypad: U moves up, D moves down, L moves left, and R moves right. Each line
whatever button you're on at the end of each line. If a move doesn't lead to a button, ignore it. 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 You can't hold it much longer, so you decide to figure out the code as you
like this: walk to the bathroom. You picture a keypad like this:
1 2 3 1 2 3
4 5 6 4 5 6
@ -28,18 +32,25 @@ Advent of Code
LURDL LURDL
UUUUD 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  You start at "5" and move up (to "2"), left (to "1"), and left (you
1. 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.  Starting from the previous button ("1"), you move right twice (to "3")
 Continuing from "9", you move left, up, right, down, and left, ending with 8. and then down three times (stopping at "9" after two moves and ignoring
 Finally, you move up four times (stopping at "2"), then down once, ending with 5. 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. 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 --- --- Part Two ---
@ -66,7 +77,7 @@ Advent of Code
Using the same instructions in your puzzle input, what is the correct bathroom 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: ** Both parts of this puzzle are complete! They provide two gold stars: **

View File

@ -2,32 +2,35 @@ Advent of Code
--- Day 3: Squares With Three Sides --- --- Day 3: Squares With Three Sides ---
Now that you can think clearly, you move deeper into the labyrinth of hallways and office Now that you can think clearly, you move deeper into the labyrinth of
furniture that makes up this part of Easter Bunny HQ. This must be a graphic design hallways and office furniture that makes up this part of Easter Bunny HQ.
department; the walls are covered in specifications for triangles. This must be a graphic design department; the walls are covered in
specifications for triangles.
Or are they? Or are they?
The design document gives the side lengths of each triangle it describes, but... 5 10 25? Some The design document gives the side lengths of each triangle it describes,
of these aren't triangles. You can't help but mark the impossible ones. 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 In a valid triangle, the sum of any two sides must be larger than the
example, the "triangle" given above is impossible, because 5 + 10 is not larger than 25. 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? 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: * The first half of this puzzle is complete! It provides one gold star: *
--- Part Two --- --- Part Two ---
Now that you've helpfully marked up their design documents, it occurs to you that triangles Now that you've helpfully marked up their design documents, it occurs to you
are specified in groups of three vertically. Each set of three numbers in a column specifies a that triangles are specified in groups of three vertically. Each set of
triangle. Rows are unrelated. 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 For example, given the following specification, numbers with the same
part of the same triangle: hundreds digit would be part of the same triangle:
101 301 501 101 301 501
102 302 502 102 302 502
@ -36,10 +39,10 @@ Advent of Code
202 402 602 202 402 602
203 403 603 203 403 603
In your puzzle input, and instead reading by columns, how many of the listed triangles are In your puzzle input, and instead reading by columns, how many of the listed
possible? triangles are possible?
Although it hasn't changed, you can still get your puzzle input. Your puzzle answer was 1544
References References

View File

@ -2,52 +2,59 @@ Advent of Code
--- Day 4: Security Through Obscurity --- --- Day 4: Security Through Obscurity ---
Finally, you come across an information kiosk with a list of rooms. Of course, the list is Finally, you come across an information kiosk with a list of rooms. Of
encrypted and full of decoy data, but the instructions to decode the list are barely hidden course, the list is encrypted and full of decoy data, but the instructions
nearby. Better remove the decoy data first. 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 Each room consists of an encrypted name (lowercase letters separated by
dash, a sector ID, and a checksum in square brackets. 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 A room is real (not a decoy) if the checksum is the five most common letters
name, in order, with ties broken by alphabetization. For example: 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.  not-a-real-room-404[oarel] is a real room.
 totally-real-room-200[decoy] is not.  totally-real-room-200[decoy] is not.
Of the real rooms from the list above, the sum of their sector IDs is 1514. 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? 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: * The first half of this puzzle is complete! It provides one gold star: *
--- Part Two --- --- 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 The room names are encrypted by a state-of-the-art shift cipher, which is
without the right software. However, the information kiosk designers at Easter Bunny HQ were nearly unbreakable without the right software. However, the information
not expecting to deal with a master cryptographer like yourself. 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 To decrypt a room name, rotate each letter forward through the alphabet a
equal to the room's sector ID. A becomes B, B becomes C, Z becomes A, and so on. Dashes become number of times equal to the room's sector ID. A becomes B, B becomes C, Z
spaces. 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? 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. Although it hasn't changed, you can still get your puzzle input.
Answer: _____________________ [ [Submit] ] Your puzzle answer was 324.
You can also [Shareon Twitter Google+ Reddit] this puzzle.
References References

View File

@ -2,48 +2,72 @@ Advent of Code
--- Day 5: How About a Nice Game of Chess? --- --- 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 The eight-character password for the door is generated one character at a
index (starting with 0). 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 A hash indicates the next character in the password if its hexadecimal
character of the password. 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: 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  The first index which produces a hash that starts with five zeroes is
first character of the password, is 1. 3231929, which we find by hashing abc3231929; the sixth character of the
 5017308 produces the next interesting hash, which starts with 000008f82..., so the second character of the password is 8. hash, and thus the first character of the password, is 1.
 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.  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? Given the actual Door ID, what is the password?
Your puzzle answer was ________. Your puzzle answer was 4543c154.
--- Part Two --- --- 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 As the door slides open, you are presented with a second door that uses a
movie is the password decrypted in order?!), the Easter Bunny engineers have worked out a better solution. 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 Instead of simply filling in the password from left to right, the hash now
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. 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: 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______.  The first interesting hash is from abc3231929, which produces
 In the previous method, 5017308 produced an interesting hash; however, it is ignored, because it specifies an invalid position (8). 0000015...; so, 5 goes in position 1: _5______.
 The second interesting hash is at index 5357525, which produces 000004e...; so, e goes in position 4: _5__e___.
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. Your puzzle input was ojvtpuvg.

View File

@ -2,13 +2,16 @@ Advent of Code
--- Day 6: Signals and Noise --- --- 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 Something is jamming your communications with Santa. Fortunately, your
a simple repetition code to get the message through. 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 - In this model, the same message is sent repeatedly. You've recorded the
almost too badly to recover. Almost. 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 eedadn
drvtee drvtee
@ -27,12 +30,14 @@ Advent of Code
dvrsen dvrsen
enarar 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. 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 --- --- 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? 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 References

View File

@ -2,44 +2,62 @@ Advent of Code
--- Day 7: Internet Protocol Version 7 --- --- 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). While snooping around the local network of EBHQ, you compile a list of IP
You'd like to figure out which IPs support TLS (transport-layer snooping). 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 An IP supports TLS if it has an Autonomous Bridge Bypass Annotation, or
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 ABBA. An ABBA is any four-character sequence which consists of a pair of two
within any hypernet sequences, which are contained by square brackets. 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: For example:
 abba[mnop]qrst supports TLS (abba outside square brackets).  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).  abcd[bddb]xyyx does not support TLS (bddb is within square brackets,
 ioxxoj[asdfgh]zxcvbn supports TLS (oxxo is outside square brackets, even though it's within a larger string). 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? How many IPs in your puzzle input support TLS?
Your puzzle answer was _____. Your puzzle answer was 118.
--- Part Two --- --- Part Two ---
You would also like to know which IPs support SSL (super-secret listening). 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), An IP supports SSL if it has an Area-Broadcast Accessor, or ABA, anywhere in
and a corresponding Byte Allocation Block, or BAB, anywhere in the hypernet sequences. An ABA is any three-character sequence which consists the supernet sequences (outside any square bracketed sections), and a
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 corresponding Byte Allocation Block, or BAB, anywhere in the hypernet
reversed positions: yxy and bab, respectively. 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: 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).  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).  aaa[kek]eke supports SSL (eke in supernet with corresponding kek in
 zazbz[bzb]cdb supports SSL (zaz has no corresponding aza, but zbz has a corresponding bzb, even though zaz and zbz overlap). 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? How many IPs in your puzzle input support SSL?
Your puzzle answer was _______. Your puzzle answer was 260.
References References

View File

@ -2,24 +2,33 @@ Advent of Code
--- Day 8: Two-Factor Authentication --- --- Day 8: Two-Factor Authentication ---
You come across a door implementing what you can only assume is an implementation of two-factor authentication You come across a door implementing what you can only assume is an
after a long game of requirements telephone. 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 To get past the door, you first swipe a keycard (no problem; there was one
code on a little screen, and you type that code on a keypad. Then, presumably, the door unlocks. 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 Unfortunately, the screen has been smashed. After a few minutes, you've
it works. Now you just have to work out what the screen would have displayed. 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 The magnetic strip on the card you swiped encodes a series of instructions
your puzzle input. The screen is 50 pixels wide and 6 pixels tall, all of which start off, and is capable of three for the screen; these instructions are your puzzle input. The screen is 50
somewhat peculiar operations: 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.  rect AxB turns on all of the pixels in a rectangle at the top-left of
 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 the screen which is A wide and B tall.
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  rotate row y=A by B shifts all of the pixels in row A (0 is the top row)
that would fall off the bottom appear at the top of the column. 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: 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  rotate column x=1 by 1 again rotates the second column down by one
to the top: 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 As you can see, this display technology is extremely powerful, and will soon
tiny-code-displaying-screen market. That's what the advertisement on the back of the display tries to convince you, dominate the tiny-code-displaying-screen market. That's what the
anyway. 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 There seems to be an intermediate check of the voltage used by the display:
screen did work, how many pixels should be lit? 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 --- --- Part Two ---
You notice that the screen is only capable of displaying capital letters; in the font it uses, each letter is 5 You notice that the screen is only capable of displaying capital letters; in
pixels wide and 6 tall. 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? After you swipe your card, what code is the screen trying to display?
Your puzzle answer was _____________. Your puzzle answer was ZFHFSFOGPO.
References References

View File

@ -2,55 +2,83 @@ Advent of Code
--- Day 9: Explosives in Cyberspace --- --- 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 Wandering around a secure area, you come across a datalink port to a new
interesting files, you find one file in particular that catches your attention. It's compressed with an experimental format, but part of the network. After briefly scanning it for interesting files, you
fortunately, the documentation for the format is nearby. 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 The format compresses a sequence of characters. Whitespace is ignored. To
added to the file, like (10x2). To decompress this marker, take the subsequent 10 characters and repeat them 2 times. Then, continue indicate that some sequence should be repeated, a marker is added to the
reading the file after the repeated data. The marker itself is not included in the decompressed output. 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 If parentheses or other characters appear within the data referenced by a
marker, and then resume looking for markers after the decompressed section. marker, that's okay - treat it like normal data, not a marker, and then
resume looking for markers after the decompressed section.
For example: For example:
 ADVENT contains no markers and decompresses to itself with no changes, resulting in a decompressed length of 6.  ADVENT contains no markers and decompresses to itself with no changes,
 A(1x5)BC repeats only the B a total of 5 times, becoming ABBBBBC for a decompressed length of 7. 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. • (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 --- --- Part Two ---
Apparently, the file actually uses version two of the format. 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, In version two, the only difference is that markers within decompressed data
provides much more substantial compression capabilities, allowing many-gigabyte files to be stored in only a few kilobytes. 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: For example:
• (3x3)XYZ still becomes XYZXYZXYZ, as the decompressed section contains no markers. • (3x3)XYZ still becomes XYZXYZXYZ, as the decompressed section contains
 X(8x2)(3x3)ABCY becomes XABCABCABCABCABCABCY, because the decompressed data from the (8x2) marker is then further decompressed, no markers.
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  X(8x2)(3x3)ABCY becomes XABCABCABCABCABCABCY, because the decompressed
with another way to get its decompressed length. 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? What is the decompressed length of the file using this improved format?
Although it hasn't changed, you can still get your puzzle input. Although it hasn't changed, you can still get your puzzle input.
Answer: _____________________ [ [Submit] ] Your puzzle answer was 10774309173.
References References

View File

@ -2,20 +2,22 @@ Advent of Code
--- Day 10: Balance Bots --- --- Day 10: Balance Bots ---
You come upon a factory in which many robots are zooming around handing small microchips to You come upon a factory in which many robots are zooming around handing
each other. small microchips to each other.
Upon closer examination, you notice that each bot only proceeds when it has two microchips, Upon closer examination, you notice that each bot only proceeds when it has
and once it does, it gives each one to a different bot or puts it in a marked "output" bin. two microchips, and once it does, it gives each one to a different bot or
Sometimes, bots take microchips from "input" bins, too. 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 Inspecting one of the microchips, it seems like they each contain a single
must use some logic to decide what to do with each chip. You access the local control computer number; the bots must use some logic to decide what to do with each chip.
and download the bots' instructions (your puzzle input). 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 Some of the instructions specify that a specific-valued microchip should be
specific bot; the rest of the instructions indicate what a given bot should do with its given to a specific bot; the rest of the instructions indicate what a given
lower-value or higher-value chip. bot should do with its lower-value or higher-value chip.
For example, consider the following instructions: 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 bot 0 gives low to output 2 and high to output 0
value 2 goes to bot 2 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  Initially, bot 1 starts with a value-3 chip, and bot 2 starts with a
value-5 chip. 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.
In the end, output bin 0 contains a value-5 microchip, output bin 1 contains a value-2  Because bot 2 has two microchips, it gives its lower one (2) to bot 1
microchip, and output bin 2 contains a value-3 microchip. In this configuration, bot number 2 and its higher one (5) to bot 0.
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  Then, bot 1 has two microchips; it puts the value-2 chip in output 1 and
value-61 microchips with value-17 microchips? 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 --- --- Part Two ---
What do you get if you multiply together the values of one chip in each of outputs 0, 1, and What do you get if you multiply together the values of one chip in each of
2? outputs 0, 1, and 2?
Your puzzle answer was _______. Your puzzle answer was 2666.
References References

222
2016/day11/problem Normal file
View File

@ -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

View File

@ -2,31 +2,40 @@ Advent of Code
--- Day 12: Leonardo's Monorail --- --- 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 You finally reach the top floor of this building: a garden with a slanted
stars to be had. 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 While sitting on a nearby bench amidst some tiger lilies, you manage to
the servers downstairs. 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 According to these documents, Easter Bunny HQ isn't just this building -
area. They're all connected by a local monorail, and there's another building not far from here! Unfortunately, being it's a collection of buildings in the nearby area. They're all connected by
night, the monorail is currently not operating. 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 You remotely connect to the monorail control systems and discover that the
password-checking logic (your puzzle input) is easy to extract, but the code it uses is strange: it's assembunny code boot sequence expects a password. The password-checking logic (your puzzle
designed for the new computer you just assembled. You'll have to execute the code and get the password. 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 The assembunny code you've extracted operates on four registers (a, b, c,
integer. However, it seems to make use of only a few instructions: 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.  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  dec x decreases the value of register x by one.
offset of 2 would skip over the next instruction.
 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: For example:
@ -37,22 +46,26 @@ Advent of Code
jnz a 2 jnz a 2
dec a 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 The above code would set register a to 41, increase its value by 2, decrease
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 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. 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 --- --- 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 As you head down the fire escape to the monorail, you notice it didn't
the position of the ignition key. 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 References

View File

@ -2,25 +2,33 @@ Advent of Code
--- Day 13: A Maze of Twisty Little Cubicles --- --- 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 You arrive at the first floor of this new building to discover a much less
last one. Instead, you are in a maze of twisty little cubicles, all alike. 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 Every location in this area is addressed by a pair of non-negative integers
open space. You can't move diagonally. The cube maze starts at 0,0 and seems to extend infinitely toward positive x and y; (x,y). Each such coordinate is either a wall or an open space. You can't
negative values are invalid, as they represent a location outside the building. You are in a small waiting area at 1,1. 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 While it seems chaotic, a nearby morale-boosting poster explains, the layout
whether a given x,y coordinate will be a wall or an open space using a simple system: 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.  Find x*x + 3*x + 2*x*y + y + y*y.
 Add the office designer's favorite number (your puzzle input).  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 even, it's an open space.
 If the number of bits that are 1 is odd, it's a wall.  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 For example, if the office designer's favorite number were 10, drawing walls
building containing 0,0 would look like this: as # and open spaces as ., the corner of the building containing 0,0 would
look like this:
0123456789 0123456789
0 .#.####.## 0 .#.####.##
@ -31,7 +39,8 @@ Advent of Code
5 ..##....#. 5 ..##....#.
6 #...##.### 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 0123456789
0 .#.####.## 0 .#.####.##
@ -42,21 +51,23 @@ Advent of Code
5 ..##OOO.#. 5 ..##OOO.#.
6 #...##.### 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? 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: * The first half of this puzzle is complete! It provides one gold star: *
--- Part Two --- --- 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. Your puzzle input is still 1364.
Answer: _____________________ Answer: 127
References References

View File

@ -2,45 +2,67 @@ Advent of Code
--- Day 14: One-Time Pad --- --- 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. In order to communicate securely with Santa while you're on this mission,
Unfortunately, you've run out of keys in your one-time pad, and so you need to generate some more. 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, To generate keys, you first get a stream of random data by taking the MD5 of
and represented in decimal); the resulting MD5 hash should be represented as a string of lowercase hexadecimal digits. 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.  It contains three of the same character in a row, like 777. Only
 One of the next 1000 hashes in the stream contains that same character five times in a row, like 77777. 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  One of the next 1000 hashes in the stream contains that same character
resume testing for keys starting with the very next hash. 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: 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  The first index which produces a triple is 18, because the MD5 hash of
pad, because none of the next thousand hashes (index 19 through index 1018) contain 88888. abc18 contains ...cc38887a5.... However, index 18 does not count as a key
 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) for your one-time pad, because none of the next thousand hashes (index 19
contains eeeee. through index 1018) contain 88888.
 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 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. 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 input was cuanljph.
Your puzzle answer was ________. Your puzzle answer was 23769.
--- Part Two --- --- 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 To implement key stretching, whenever you generate a hash, before you use
total of 2016 additional hashings. Always use lowercase hexadecimal representations of hashes. 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: For example, to find the stretched hash for index 0 and salt abc:
@ -50,18 +72,26 @@ Advent of Code
• ...repeat many times... • ...repeat many times...
 Then, find the MD5 hash of that hash: a107ff634856bb300138cac6568c0f24.  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 So, the stretched hash for index 0 in this situation is a107ff.... In the
times, for a total of 2017 uses of MD5. 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 first triple (222, at index 5) has no matching 22222 in the next
 The second triple (eee, at index 10) hash a matching eeeee at index 89, and so it is the first key. thousand hashes.
 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?  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. Your puzzle input was cuanljph.

View File

@ -2,49 +2,76 @@ Advent of Code
--- Day 15: Timing is Everything --- --- 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 halls open into an interior plaza containing a large kinetic sculpture.
the maze of spinning pieces. 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 Part of the sculpture is even interactive! When a button is pressed, a
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. 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 The discs pause their motion each second and come in different sizes; they
next. 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 Furthermore, the discs are spaced out so that after you push the button, one
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. 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: 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 #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. 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 If you press the button exactly at time=0, the capsule would start to fall;
disc, the next position is 0, and the capsule falls through the slot. 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 Then, at time=2, the capsule reaches the second disc. The second disc has
only a slot at position 0, the capsule bounces away. 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 If, however, you wait until time=5 to push the button, then when the capsule
to position 0). In this case, the capsule would fall through the discs and come out of the machine. 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 --- --- 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. Although it hasn't changed, you can still get your puzzle input.
Answer: _____________________ Answer: 3045959
References References

View File

@ -2,20 +2,27 @@ Advent of Code
--- Day 16: Dragon Checksum --- --- Day 16: Dragon Checksum ---
You're done scanning this part of the network, but you've left traces of your presence. You need to You're done scanning this part of the network, but you've left traces of
overwrite some disks with random-looking data to cover your tracks and update the local security system your presence. You need to overwrite some disks with random-looking data to
with a new checksum for those disks. 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 For the data to not be suspiscious, it needs to have certain properties;
detected as tampering. To generate appropriate random data, you'll need to use a modified dragon curve. 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 Start with an appropriate initial state (your puzzle input). Then, so long
yet to fill the disk, repeat the following steps: 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".  Call the data you have at this point "a".
 Make a copy of "a"; call this copy "b".  Make a copy of "a"; call this copy "b".
 Reverse the order of the characters in "b".  Reverse the order of the characters in "b".
 In "b", replace all instances of 0 with 1 and all 1s with 0.  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".  The resulting data is "a", then a single 0, then "b".
For example, after a single step of this process, 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. 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 Once the data has been generated, you also need to create a checksum of that
only for the data that fits on the disk, even if you generated more data than that in the previous step. 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 The checksum for some given data is created by considering each
input data. If the two characters match (00 or 11), the next checksum character is a 1. If the characters non-overlapping pair of characters in the input data. If the two characters
do not match (01 or 10), the next checksum character is a 0. This should produce a new string which is match (00 or 11), the next checksum character is a 1. If the characters do
exactly half as long as the original. If the length of the checksum is even, repeat the process until you not match (01 or 10), the next checksum character is a 0. This should
end up with a checksum with an odd length. 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 For example, suppose we want to fill a disk of length 12, and when we
least length 12, the first 12 characters are 110010110100. To generate its checksum: 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.  Consider each pair: 11, 00, 10, 11, 01, 00.
 These are same, same, different, same, different, same, producing 110101.  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).  The pairs are 11 (same), 01 (different), 01 (different).
 This produces the checksum 100, which has an odd length, so we stop.  This produces the checksum 100, which has an odd length, so we stop.
Therefore, the checksum for 110010110100 is 100. 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 Combining all of these steps together, suppose you want to fill a disk of
of 10000: length 20 using an initial state of 10000:
 Because 10000 is too short, we first use the modified dragon curve to make it longer.  Because 10000 is too short, we first use the modified dragon curve to
 After one round, it becomes 10000011110 (11 characters), still too short. make it longer.
 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:  After one round, it becomes 10000011110 (11 characters), still too
10000011110010000111. short.
 Next, we start calculating the checksum; after one round, we have 0111110101, which 10 characters long
(even), so we continue.  After two rounds, it becomes 10000011110010000111110 (23 characters),
 After two rounds, we have 01100, which is 5 characters long (odd), so we are done. 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. 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 The first disk you have to fill has length 272. Using the initial state in
correct checksum? 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: * 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. Your puzzle input is still 00111101111101000.
Answer: _____________________ Answer: 10101011110100011.
References References

View File

@ -2,9 +2,9 @@ Advent of Code
--- Day 17: Two Steps Forward --- --- Day 17: Two Steps Forward ---
You're trying to access a secure vault protected by a 4x4 grid of small rooms connected by You're trying to access a secure vault protected by a 4x4 grid of small
doors. You start in the top-left room (marked S), and you can access the vault (marked V) once rooms connected by doors. You start in the top-left room (marked S), and you
you reach the bottom-right room: can access the vault (marked V) once you reach the bottom-right room:
######### #########
#S| | | # #S| | | #
@ -18,52 +18,56 @@ Advent of Code
Fixed walls are marked with #, and doors are marked with - or |. 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 The doors in your current room are either open or closed (and locked) based
MD5 hash of a passcode (your puzzle input) followed by a sequence of uppercase characters on the hexadecimal MD5 hash of a passcode (your puzzle input) followed by a
representing the path you have taken so far (U for up, D for down, L for left, and R for sequence of uppercase characters representing the path you have taken so far
right). (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 Only the first four characters of the hash are used; they represent,
up, down, left, and right from your current position. Any b, c, d, e, or f means that the respectively, the doors up, down, left, and right from your current
corresponding door is open; any other character (any number or a) means that the corresponding position. Any b, c, d, e, or f means that the corresponding door is open;
door is closed and locked. 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 To access the vault, all you need to do is reach the bottom-right room;
opens the vault and all doors in the maze. 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 For example, suppose the passcode is hijkl. Initially, you have taken no
path is empty: you simply find the MD5 hash of hijkl alone. The first four characters of this steps, and so your path is empty: you simply find the MD5 hash of hijkl
hash are ced9, which indicate that up is open (c), down is open (e), left is open (d), and alone. The first four characters of this hash are ced9, which indicate that
right is closed and locked (9). Because you start in the top-left corner, there are no "up" or 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. "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, Next, having gone only one step (down, or D), you find the hash of hijklD.
which indicates that you can go back up, left (but that's a wall), or right. Going right means This produces f2bc, which indicates that you can go back up, left (but
hashing hijklDR to get 5745 - all doors closed and locked. However, going up instead is that's a wall), or right. Going right means hashing hijklDR to get 5745 -
worthwhile: even though it returns you to the room you started in, your path would then be DU, all doors closed and locked. However, going up instead is worthwhile: even
opening a different set of doors. 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 After going DU (and then hashing hijklDU to get 528e), only the right door
going DUR, all doors lock. (Fortunately, your actual passcode is not hijkl). 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 Passcodes actually used by Easter Bunny Vault Security do allow access to
know the right path. For example: the vault if you know the right path. For example:
 If your passcode were ihgpwlah, the shortest path would be DDRRRD.  If your passcode were ihgpwlah, the shortest path would be DDRRRD.
 With kglvqrro, the shortest path would be DDUDRLRRUDRD.  With kglvqrro, the shortest path would be DDUDRLRRUDRD.
 With ulqzkmiv, the shortest would be DRURDRUDDLLDLUURRDULRLDUUDDDRR.  With ulqzkmiv, the shortest would be DRURDRUDDLLDLUURRDULRLDUUDDDRR.
Given your vault's passcode, what is the shortest path (the actual path, not just the length) Given your vault's passcode, what is the shortest path (the actual path, not
to reach the vault? just the length) to reach the vault?
Your puzzle answer was __________________. Your puzzle answer was DRRDRLDURD.
--- Part Two --- --- Part Two ---
You're curious how robust this security solution really is, and so you decide to find longer You're curious how robust this security solution really is, and so you
and longer paths which still provide access to the vault. You remember that paths always end decide to find longer and longer paths which still provide access to the
the first time they reach the bottom-right room (that is, they can never pass through it, only vault. You remember that paths always end the first time they reach the
end in it). bottom-right room (that is, they can never pass through it, only end in it).
For example: For example:
@ -73,7 +77,7 @@ Advent of Code
What is the length of the longest path that reaches the vault? What is the length of the longest path that reaches the vault?
Your puzzle answer was _______. Your puzzle answer was 618.
References References

View File

@ -2,28 +2,32 @@ Advent of Code
--- Day 18: Like a Rogue --- --- 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 As you enter this room, you hear a loud click! Some of the tiles in the
pressure plates for traps, and the trap you just triggered has run out of... whatever it tried floor here seem to be pressure plates for traps, and the trap you just
to do to you. You doubt you'll be so lucky next time. 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 Upon closer examination, the traps and safe tiles in this room seem to
tiles are arranged into rows that are all the same width; you take note of the safe tiles (.) follow a pattern. The tiles are arranged into rows that are all the same
and traps (^) in the first row (your puzzle input). 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 The type of tile (trapped or safe) in each row is based on the types of the
position, and to either side of that position, in the previous row. (If either side is off tiles in the same position, and to either side of that position, in the
either end of the row, it counts as "safe" because there isn't a trap embedded in the wall.) 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 For example, suppose you know the first row (with tiles marked by letters)
determine the next row (with tiles marked by numbers): and want to determine the next row (with tiles marked by numbers):
ABCDE ABCDE
12345 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 The type of tile 2 is based on the types of tiles A, B, and C; the type of
tiles D, E, and an imaginary "safe" tile. Let's call these three tiles from the previous row tile 5 is based on tiles D, E, and an imaginary "safe" tile. Let's call
the left, center, and right tiles, respectively. Then, a new tile is a trap only in one of the these three tiles from the previous row the left, center, and right tiles,
following situations: 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 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.  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. 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 Then, starting with the row ..^^., you can determine the next row by
each new tile: applying those rules to each new tile:
 The leftmost character on the next row considers the left (nonexistent, so we assume  The leftmost character on the next row considers the left (nonexistent,
"safe"), center (the first ., which means "safe"), and right (the second ., also "safe") so we assume "safe"), center (the first ., which means "safe"), and right
tiles on the previous row. Because all of the trap rules require a trap in at least one of (the second ., also "safe") tiles on the previous row. Because all of the
the previous three tiles, the first tile on this new row is also safe, .. trap rules require a trap in at least one of the previous three tiles, the
 The second character on the next row considers its left (.), center (.), and right (^) first tile on this new row is also safe, ..
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  The second character on the next row considers its left (.), center (.),
to the next row, using the same rules, and get ^^..^. After determining two new rows, our map and right (^) tiles from the previous row. This matches the fourth rule:
looks like this: 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. 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 Starting with the map in your puzzle input, in a total of 40 rows (including
row), how many safe tiles are there? the starting row), how many safe tiles are there?
Your puzzle answer ________. Your puzzle answer 1913.
--- Part Two --- --- Part Two ---
How many safe tiles are there in a total of 400000 rows? How many safe tiles are there in a total of 400000 rows?
Your puzzle answer was ________. Your puzzle answer was 19993564.
References References

View File

@ -5,10 +5,10 @@ Advent of Code
The Elves contact you over a highly secure emergency channel. Back at the The Elves contact you over a highly secure emergency channel. Back at the
North Pole, the Elves are busy misunderstanding White Elephant parties. North Pole, the Elves are busy misunderstanding White Elephant parties.
Each Elf brings a present. They all sit in a circle, numbered starting Each Elf brings a present. They all sit in a circle, numbered starting with
with position 1. Then, starting with the first Elf, they take turns position 1. Then, starting with the first Elf, they take turns stealing all
stealing all the presents from the Elf to their left. An Elf with no the presents from the Elf to their left. An Elf with no presents is removed
presents is removed from the circle and does not take turns. from the circle and does not take turns.
For example, with five Elves (numbered 1 to 5): 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 So, with five Elves, the Elf that sits starting in position 3 gets all the
presents. presents.
With the number of Elves given in your puzzle input, which Elf gets all With the number of Elves given in your puzzle input, which Elf gets all the
the presents? presents?
Your puzzle input was 3014387. Your puzzle input was 3014387.
Your puzzle answer was __________. Your puzzle answer was 1834471.
--- Part Two --- --- Part Two ---
Realizing the folly of their present-exchange rules, the Elves agree to Realizing the folly of their present-exchange rules, the Elves agree to
instead steal presents from the Elf directly across the circle. If two instead steal presents from the Elf directly across the circle. If two Elves
Elves are across the circle, the one on the left (from the perspective of are across the circle, the one on the left (from the perspective of the
the stealer) is stolen from. The other rules remain unchanged: Elves with stealer) is stolen from. The other rules remain unchanged: Elves with no
no presents are removed from the circle entirely, and the other elves move presents are removed from the circle entirely, and the other elves move in
in slightly to keep the circle evenly spaced. slightly to keep the circle evenly spaced.
For example, with five Elves (again numbered 1 to 5): For example, with five Elves (again numbered 1 to 5):
@ -52,8 +52,8 @@ Advent of Code
4 3 4 3
 Elves 3 and 4 are across the circle; Elf 3's present is stolen, being  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 the one to the left. Elf 3 leaves the circle, and the rest of the Elves
Elves move in: move in:
1 1 1 1
5 2 --> 5 2 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 So, with five Elves, the Elf that sits starting in position 2 gets all the
presents. presents.
With the number of Elves given in your puzzle input, which Elf now gets With the number of Elves given in your puzzle input, which Elf now gets all
all the presents? the presents?
Your puzzle input was 3014387. Your puzzle input was 3014387.
Your puzzle answer was __________. Your puzzle answer was 1420064.
References References

View File

@ -2,30 +2,37 @@ Advent of Code
--- Day 20: Firewall Rules --- --- 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 You'd like to set up a small hidden computer here so you can use it to get
IP addresses. 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 You've retrieved the list of blocked IPs from the firewall, but the list
written in dot-decimal notation, they are written as plain 32-bit integers, which can have any value from 0 through 4294967295, inclusive. 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 5-8
0-2 0-2
4-7 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 The blacklist specifies ranges of IPs (inclusive of both the start and end
only numbers not in any range. 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 --- --- Part Two ---
How many IPs are allowed by the blacklist? How many IPs are allowed by the blacklist?
Your puzzle answer was _______________. Your puzzle answer was 117.
References References

View File

@ -2,51 +2,86 @@ Advent of Code
--- Day 21: Scrambled Letters and Hash --- --- 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 The computer system you're breaking into uses a weird scrambling function to
your own scrambled password so you can add it to the system; you just have to implement the scrambler. 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 The scrambling function is a series of operations (the exact list is
scrambled, apply each operation in succession to the string. The individual operations behave as follows: 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 position X with position Y means that the letters at indexes X and
 swap letter X with letter Y means that the letters X and Y should be swapped (regardless of where they appear in the string). Y (counting from 0) should be swapped.
 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 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.  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.  reverse positions 0 through 4 causes the entire string to be reversed,
 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. producing abcde.
 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  rotate left 1 step shifts all letters left one position, causing the
equal to that index (2): ecabd. first letter to wrap to the end of the string: bcdea.
 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.  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. 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 Now, you just need to generate a new scrambled password and you can access
puzzle input, what is the result of scrambling abcdefgh? 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 --- --- 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 You scrambled the password correctly, but you discover that you can't
un-scramble one of the existing passwords by reversing the scrambling process. 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? What is the un-scrambled version of the scrambled password fbgdceah?
Your puzzle answer was ________. Your puzzle answer was bacdefgh.
References References

176
2016/day22/problem Normal file
View File

@ -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

View File

@ -2,34 +2,50 @@ Advent of Code
--- Day 23: Safe Cracking --- --- 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 This is one of the top floors of the nicest tower in EBHQ. The Easter
a safe hidden behind a painting, and who wouldn't hide a star in a safe behind a painting? 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 The safe has a digital screen and keypad for code entry. A sticky note
it: "eggs". The painting is of a large rabbit coloring some eggs. You see 7. 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 When you go to type the code, though, nothing appears on the display;
hands, apparently having been smashed. Behind it is some kind of socket - one that matches a connector in your instead, the keypad comes apart in your hands, apparently having been
prototype computer! You pull apart the smashed keypad and extract the logic circuit, plug it into your computer, smashed. Behind it is some kind of socket - one that matches a connector in
and plug your computer into the safe. 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 Now, you just need to figure out what output the keypad would have sent to
code from the logic chip (your puzzle input). 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 The code looks like it uses almost the same architecture and instruction set
should be able to use the same assembunny interpreter for this as you did there, but with one new instruction: 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 tgl x toggles the instruction x away (pointing at instructions like jnz
means backward): 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.  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  If an attempt is made to toggle an instruction outside the program,
instruction, skip it instead. nothing happens.
 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 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: For example, given this program:
@ -42,34 +58,45 @@ Advent of Code
dec a dec a
 cpy 2 a initializes register a to 2.  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.  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. 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 The rest of the electronics seem to place the keypad entry (the number of
then send the value left in register a to the safe. 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? What value should be sent to the safe?
Your puzzle answer was ________. Your puzzle answer was 10584.
--- Part Two --- --- 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 You're quite sure your logic is working correctly, so the only other thing
it turns out, colored eggs are still eggs. Now you count 12. 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 As you run the program with this new input, the prototype computer begins to
long, and whether the lack of any instruction more powerful than "add one" has anything to do with it. Don't 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? bunnies usually multiply?
Anyway, what value should actually be sent to the safe? Anyway, what value should actually be sent to the safe?
Your puzzle answer was ____________. Your puzzle answer was 479007144.
References References

View File

@ -2,19 +2,23 @@ Advent of Code
--- Day 24: Air Duct Spelunking --- --- 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 You've finally met your match; the doors that provide access to the roof are
related electronics are inaccessible. You simply can't reach them. 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. 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 It's not a very fast little robot, but you reconfigure it to be able to
have been routed through the HVAC system. If you can direct it to each of those locations, you should be able to bypass interface with some of the exposed wires that have been routed through the
the security controls. 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 You extract the duct layout for this area from some blueprints you acquired
marked (your puzzle input). 0 is your current location, from which the cleaning robot embarks; the other numbers are (in and create a map with the relevant locations marked (your puzzle input). 0
no particular order) the locations the robot needs to visit at least once each. Walls are marked as #, and open passages is your current location, from which the cleaning robot embarks; the other
are marked as .. Numbers behave like open passages. 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: For example, suppose you have a map like the following:
@ -24,29 +28,33 @@ Advent of Code
#4.......3# #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)  0 to 4 (2 steps)
 4 to 1 (4 steps; it can't move diagonally)  4 to 1 (4 steps; it can't move diagonally)
 1 to 2 (6 steps)  1 to 2 (6 steps)
 2 to 3 (2 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 Since the robot isn't very fast, you need to find it the shortest route.
example, a total of 14) required to start at 0 and then visit every other location at least once. 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 Given your actual map, and starting from location 0, what is the fewest
number marked on the map at least once? 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 --- --- 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 What is the fewest number of steps required to start at 0, visit every non-0
then return to 0? number marked on the map at least once, and then return to 0?
Your puzzle answer was _____. Your puzzle answer was 744.
References References

View File

@ -2,51 +2,61 @@ Advent of Code
--- Day 25: Clock Signal --- --- 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 There's not much time now - it's already Christmas, but you're nowhere near
these stars to the sleigh in time. 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 However, maybe the huge antenna up here can offer a solution. After all, the
needs the timing data they provide, and you happen to have a massive signal generator right here. 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. Nothing happens.
You call the service number printed on the side of the antenna and quickly explain the situation. "I'm not sure what You call the service number printed on the side of the antenna and quickly
kind of equipment you have connected over there," he says, "but you need a clock signal." You try to explain that this explain the situation. "I'm not sure what kind of equipment you have
is a signal for a clock. 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 "No, no, a clock signal - timing information so the antenna computer knows
endless, alternating pattern of 0, 1, 0, 1, 0, 1, 0, 1, 0, 1...." He trails off. 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. You ask if the antenna can handle a clock signal at the frequency you would
"There's no way it can! The only antenna we've installed capable of that is on top of a top-secret Easter Bunny need to use for the data from the stars. "There's no way it can! The only
installation, and you're definitely not-" You hang up the phone. 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 You've extracted the antenna's clock signal generation assembunny code (your
with code you worked on just recently. puzzle input); it looks mostly compatible with code you worked on just
recently.
This antenna code, being a signal generator, uses one extra instruction: 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 The code takes a value (via register a) that describes the signal to
have to find the input to produce the right signal through experimentation. 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 What is the lowest positive integer that can be used to initialize register
signal of 0, 1, 0, 1... repeating forever? 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 --- --- 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 The antenna is ready. Now, all you need is the fifty stars required to
have enough. 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 You look toward the sky in desperation... suddenly noticing that a lone star
antenna! Only 49 more to go. has been installed at the top of the antenna! Only 49 more to go.
If you like, you can [ [Retransmit the Signal] ] . If you like, you can [ [Retransmit the Signal] ] .