adventofcode/2016/day08/problem

100 lines
3.4 KiB
Plaintext
Raw Normal View History

2016-12-08 15:16:22 +00:00
Advent of Code
--- Day 8: Two-Factor Authentication ---
2018-03-15 16:24:23 +00:00
You come across a door implementing what you can only assume is an
implementation of two-factor authentication after a long game of
requirements telephone.
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
To get past the door, you first swipe a keycard (no problem; there was one
on a nearby desk). Then, it displays a code on a little screen, and you type
that code on a keypad. Then, presumably, the door unlocks.
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
Unfortunately, the screen has been smashed. After a few minutes, you've
taken everything apart and figured out how it works. Now you just have to
work out what the screen would have displayed.
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
The magnetic strip on the card you swiped encodes a series of instructions
for the screen; these instructions are your puzzle input. The screen is 50
pixels wide and 6 pixels tall, all of which start off, and is capable of
three somewhat peculiar operations:
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
 rect AxB turns on all of the pixels in a rectangle at the top-left of
the screen which is A wide and B tall.
 rotate row y=A by B shifts all of the pixels in row A (0 is the top row)
right by B pixels. Pixels that would fall off the right end appear at the
left end of the row.
 rotate column x=A by B shifts all of the pixels in column A (0 is the
left column) down by B pixels. Pixels that would fall off the bottom
appear at the top of the column.
2016-12-08 15:16:22 +00:00
For example, here is a simple sequence on a smaller screen:
 rect 3x2 creates a small rectangle in the top-left corner:
###....
###....
.......
 rotate column x=1 by 1 rotates the second column down by one pixel:
#.#....
###....
.#.....
 rotate row y=0 by 4 rotates the top row right by four pixels:
....#.#
###....
.#.....
2018-03-15 16:24:23 +00:00
 rotate column x=1 by 1 again rotates the second column down by one
pixel, causing the bottom pixel to wrap back to the top:
2016-12-08 15:16:22 +00:00
.#..#.#
#.#....
.#.....
2018-03-15 16:24:23 +00:00
As you can see, this display technology is extremely powerful, and will soon
dominate the tiny-code-displaying-screen market. That's what the
advertisement on the back of the display tries to convince you, anyway.
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
There seems to be an intermediate check of the voltage used by the display:
after you swipe your card, if the screen did work, how many pixels should be
lit?
2016-12-08 15:16:22 +00:00
2018-03-15 16:24:23 +00:00
Your puzzle answer was 119.
2016-12-08 15:16:22 +00:00
--- Part Two ---
2018-03-15 16:24:23 +00:00
You notice that the screen is only capable of displaying capital letters; in
the font it uses, each letter is 5 pixels wide and 6 tall.
2016-12-08 15:16:22 +00:00
After you swipe your card, what code is the screen trying to display?
2018-03-15 16:24:23 +00:00
Your puzzle answer was ZFHFSFOGPO.
2016-12-08 15:16:22 +00:00
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/Multi-factor_authentication
. https://en.wikipedia.org/wiki/Requirement
. https://en.wikipedia.org/wiki/Chinese_whispers
. https://www.google.com/search?q=tiny+lcd&tbm=isch
. http://adventofcode.com/2016
. http://adventofcode.com/2016/day/8/input