2018-03-15 16:24:23 +00:00
|
|
|
|
Advent of Code
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
--- Day 6: Probably a Fire Hazard ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Because your neighbors keep defeating you in the holiday house decorating
|
|
|
|
|
contest year after year, you've decided to deploy one million lights in a
|
|
|
|
|
1000x1000 grid.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Furthermore, because you've been especially nice this year, Santa has mailed
|
|
|
|
|
you instructions on how to display the ideal lighting configuration.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
Lights in your grid are numbered from 0 to 999 in each direction; the lights
|
|
|
|
|
at each corner are at 0,0, 0,999, 999,999, and 999,0. The instructions
|
|
|
|
|
include whether to turn on, turn off, or toggle various inclusive ranges
|
|
|
|
|
given as coordinate pairs. Each coordinate pair represents opposite corners
|
|
|
|
|
of a rectangle, inclusive; a coordinate pair like 0,0 through 2,2 therefore
|
2016-12-16 22:21:15 +00:00
|
|
|
|
refers to 9 lights in a 3x3 square. The lights all start turned off.
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
To defeat your neighbors this year, all you have to do is set up your lights
|
|
|
|
|
by doing the instructions Santa sent you in order.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
• turn on 0,0 through 999,999 would turn on (or leave on) every light.
|
2018-03-15 16:24:23 +00:00
|
|
|
|
|
|
|
|
|
• toggle 0,0 through 999,0 would toggle the first line of 1000 lights,
|
|
|
|
|
turning off the ones that were on, and turning on the ones that were off.
|
|
|
|
|
|
|
|
|
|
• turn off 499,499 through 500,500 would turn off (or leave off) the
|
|
|
|
|
middle four lights.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
After following the instructions, how many lights are lit?
|
|
|
|
|
|
|
|
|
|
Your puzzle answer was 377891.
|
|
|
|
|
|
|
|
|
|
--- Part Two ---
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
You just finish implementing your winning light pattern when you realize you
|
|
|
|
|
mistranslated Santa's message from Ancient Nordic Elvish.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The light grid you bought actually has individual brightness controls; each
|
|
|
|
|
light can have a brightness of zero or more. The lights all start at zero.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The phrase turn on actually means that you should increase the brightness of
|
|
|
|
|
those lights by 1.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The phrase turn off actually means that you should decrease the brightness
|
|
|
|
|
of those lights by 1, to a minimum of zero.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
The phrase toggle actually means that you should increase the brightness of
|
|
|
|
|
those lights by 2.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
What is the total brightness of all lights combined after following Santa's
|
|
|
|
|
instructions?
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
|
|
• turn on 0,0 through 0,0 would increase the total brightness by 1.
|
2018-03-15 16:24:23 +00:00
|
|
|
|
|
|
|
|
|
• toggle 0,0 through 999,999 would increase the total brightness by
|
|
|
|
|
2000000.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
Your puzzle answer was 14110788.
|
|
|
|
|
|
|
|
|
|
Both parts of this puzzle are complete! They provide two gold stars: **
|
|
|
|
|
|
2018-03-15 16:24:23 +00:00
|
|
|
|
At this point, you should return to your advent calendar and try another
|
|
|
|
|
puzzle.
|
2016-12-16 22:21:15 +00:00
|
|
|
|
|
|
|
|
|
If you still want to see it, you can get your puzzle input.
|
|
|
|
|
|
|
|
|
|
References
|
|
|
|
|
|
|
|
|
|
Visible links
|
|
|
|
|
. http://adventofcode.com/
|
|
|
|
|
. http://adventofcode.com/about
|
|
|
|
|
. http://adventofcode.com/stats
|
|
|
|
|
. http://adventofcode.com/leaderboard
|
|
|
|
|
. http://adventofcode.com/settings
|
|
|
|
|
. http://adventofcode.com/auth/logout
|
|
|
|
|
. http://adventofcode.com/
|
|
|
|
|
. http://adventofcode.com/day/6/input
|