4 <meta charset=
"utf-8"/>
5 <title>Day
11 - Advent of Code
2019</title>
6 <!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]-->
7 <link href='//fonts.googleapis.com/css?family=Source+Code+Pro:
300&subset=latin,latin-ext' rel='stylesheet' type='text/css'
>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/static/style.css?24"/>
9 <link rel=
"stylesheet alternate" type=
"text/css" href=
"/static/highcontrast.css?0" title=
"High Contrast"/>
10 <link rel=
"shortcut icon" href=
"/favicon.png"/>
16 Oh, hello! Funny seeing you here.
18 I appreciate your enthusiasm, but you aren't going to find much down here.
19 There certainly aren't clues to any of the puzzles. The best surprises don't
20 even appear in the source until you unlock them for real.
22 Please be careful with automated requests; I'm not a massive company, and I can
23 only take so much traffic. Please be considerate so that everyone gets to play.
25 If you're curious about how Advent of Code works, it's running on some custom
26 Perl code. Other than a few integrations (auth, analytics, ads, social media),
27 I built the whole thing myself, including the design, animations, prose, and
30 The puzzles are most of the work; preparing a new calendar and a new set of
31 puzzles each year takes all of my free time for 4-5 months. A lot of effort
32 went into building this thing - I hope you're enjoying playing it as much as I
33 enjoyed making it for you!
35 If you'd like to hang out, I'm @ericwastl on Twitter.
90 <header><div><h1 class=
"title-global"><a href=
"/">Advent of Code
</a></h1><nav><ul><li><a href=
"/2019/about">[About]
</a></li><li><a href=
"/2019/events">[Events]
</a></li><li><a href=
"https://teespring.com/adventofcode-2019" target=
"_blank">[Shop]
</a></li><li><a href=
"/2019/settings">[Settings]
</a></li><li><a href=
"/2019/auth/logout">[Log Out]
</a></li></ul></nav><div class=
"user">Neil Smith
<a href=
"/2019/support" class=
"supporter-badge" title=
"Advent of Code Supporter">(AoC++)
</a> <span class=
"star-count">22*
</span></div></div><div><h1 class=
"title-event"> <span class=
"title-event-wrap">0x0000|
</span><a href=
"/2019">2019</a><span class=
"title-event-wrap"></span></h1><nav><ul><li><a href=
"/2019">[Calendar]
</a></li><li><a href=
"/2019/support">[AoC++]
</a></li><li><a href=
"/2019/sponsors">[Sponsors]
</a></li><li><a href=
"/2019/leaderboard">[Leaderboard]
</a></li><li><a href=
"/2019/stats">[Stats]
</a></li></ul></nav></div></header>
93 <div id=
"sponsor"><div class=
"quiet">Our
<a href=
"/2019/sponsors">sponsors
</a> help make Advent of Code possible:
</div><div class=
"sponsor"><a href=
"https://formlabs.com/" target=
"_blank" onclick=
"if(ga)ga('send','event','sponsor','sidebar',this.href);" rel=
"noopener">Formlabs
</a> - You don
't need elves when you have
3D printers...
</div></div>
97 <script>window.addEventListener('click', function(e,s,r){if(e.target.nodeName==='CODE'&&e.detail===
3){s=window.getSelection();s.removeAllRanges();r=document.createRange();r.selectNodeContents(e.target);s.addRange(r);}});
</script>
98 <article class=
"day-desc"><h2>--- Day
11: Space Police ---
</h2><p>On the way to Jupiter, you're
<a href=
"https://www.youtube.com/watch?v=KwY28rpyKDE">pulled over
</a> by the
<em>Space Police
</em>.
</p>
99 <p>"Attention, unmarked spacecraft! You are in violation of Space Law! All spacecraft must have a clearly visible <em>registration identifier</em>! You have 24 hours to comply or be sent to <a href="https://www.youtube.com/watch?v=BVn1oQL9sWg&t=
5">Space Jail</a>!"</p>
100 <p>Not wanting to be sent to Space Jail, you radio back to the Elves on Earth for help. Although it takes almost three hours for their reply signal to reach you, they send instructions for how to power up the
<em>emergency hull painting robot
</em> and even provide a small
<a href=
"9">Intcode program
</a> (your puzzle input) that will cause it to paint your ship appropriately.
</p>
101 <p>There's just one problem: you don't have an emergency hull painting robot.
</p>
102 <p>You'll need to build a new emergency hull painting robot. The robot needs to be able to move around on the grid of square panels on the side of your ship, detect the color of its current panel, and paint its current panel
<em>black
</em> or
<em>white
</em>. (All of the panels are currently
<em>black
</em>.)
</p>
103 <p>The Intcode program will serve as the brain of the robot. The program uses input instructions to access the robot's camera: provide
<code>0</code> if the robot is over a
<em>black
</em> panel or
<code>1</code> if the robot is over a
<em>white
</em> panel. Then, the program will output two values:
</p>
105 <li>First, it will output a value indicating the
<em>color to paint the panel
</em> the robot is over:
<code>0</code> means to paint the panel
<em>black
</em>, and
<code>1</code> means to paint the panel
<em>white
</em>.
</li>
106 <li>Second, it will output a value indicating the
<em>direction the robot should turn
</em>:
<code>0</code> means it should turn
<em>left
90 degrees
</em>, and
<code>1</code> means it should turn
<em>right
90 degrees
</em>.
</li>
108 <p>After the robot turns, it should always move
<em>forward exactly one panel
</em>. The robot starts facing
<em>up
</em>.
</p>
109 <p>The robot will continue running for a while like this and halt when it is finished drawing. Do not restart the Intcode computer inside the robot during this process.
</p>
110 <p>For example, suppose the robot is about to start running. Drawing black panels as
<code>.
</code>, white panels as
<code>#
</code>, and the robot pointing the direction it is facing (
<code>< ^
> v
</code>), the initial state and region near the robot looks like this:
</p>
117 <p>The panel under the robot (not visible here because a
<code>^
</code> is shown instead) is also black, and so any input instructions at this point should be provided
<code>0</code>. Suppose the robot eventually outputs
<code>1</code> (paint white) and then
<code>0</code> (turn left). After taking these actions and moving forward one panel, the region now looks like this:
</p>
124 <p>Input instructions should still be provided
<code>0</code>. Next, the robot might output
<code>0</code> (paint black) and then
<code>0</code> (turn left):
</p>
131 <p>After more outputs (
<code>1,
0</code>,
<code>1,
0</code>):
</p>
138 <p>The robot is now back where it started, but because it is now on a white panel, input instructions should be provided
<code>1</code>. After several more outputs (
<code>0,
1</code>,
<code>1,
0</code>,
<code>1,
0</code>), the area looks like this:
</p>
145 <p>Before you deploy the robot, you should probably have an estimate of the area it will cover: specifically, you need to know the
<em>number of panels it paints at least once
</em>, regardless of color. In the example above, the robot painted
<em><code>6</code> panels
</em> at least once. (It painted its starting panel twice, but that panel is
<a href=
"https://www.youtube.com/watch?v=KjsSvjA5TuE">still only counted once
</a>; it also never painted the panel it ended on.)
</p>
146 <p>Build a new emergency hull painting robot and run the Intcode program on it.
<em>How many panels does it paint at least once?
</em></p>
148 <p>Your puzzle answer was
<code>2343</code>.
</p><article class=
"day-desc"><h2 id=
"part2">--- Part Two ---
</h2><p>You're not sure what it's trying to paint, but it's definitely not a
<em>registration identifier
</em>. The Space Police are getting impatient.
</p>
149 <p>Checking your external ship cameras again, you notice a white panel marked
"emergency hull painting robot starting panel". The rest of the panels are
<em>still black
</em>, but it looks like the robot was expecting to
<em>start on a white panel
</em>, not a black one.
</p>
150 <p>Based on the
<span title=
"Just be glad it wasn't a full set of Space Law Space Books; the number of pages is *astronomical*.">Space Law Space Brochure
</span> that the Space Police attached to one of your windows, a valid registration identifier is always
<em>eight capital letters
</em>. After starting the robot on a single
<em>white panel
</em> instead,
<em>what registration identifier does it paint
</em> on your hull?
</p>
152 <p>Your puzzle answer was
<code>JFBERBUH
</code>.
</p><p class=
"day-success">Both parts of this puzzle are complete! They provide two gold stars: **
</p>
153 <p>At this point, you should
<a href=
"/2019">return to your Advent calendar
</a> and try another puzzle.
</p>
154 <p>If you still want to see it, you can
<a href=
"11/input" target=
"_blank">get your puzzle input
</a>.
</p>
155 <p>You can also
<span class=
"share">[Share
<span class=
"share-content">on
156 <a href=
"https://twitter.com/intent/tweet?text=I%27ve+completed+%22Space+Police%22+%2D+Day+11+%2D+Advent+of+Code+2019&url=https%3A%2F%2Fadventofcode%2Ecom%2F2019%2Fday%2F11&related=ericwastl&hashtags=AdventOfCode" target=
"_blank">Twitter
</a>
157 <a href=
"javascript:void(0);" onclick=
"var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=I%27ve+completed+%22Space+Police%22+%2D+Day+11+%2D+Advent+of+Code+2019+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2019%2Fday%2F11'}else{return false;}" target=
"_blank">Mastodon
</a
158 ></span>]
</span> this puzzle.
</p>
163 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
164 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=
1*new Date();a=s.createElement(o),
165 m=s.getElementsByTagName(o)[
0];a.async=
1;a.src=g;m.parentNode.insertBefore(a,m)
166 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
167 ga('create', 'UA-
69522494-
1', 'auto');
168 ga('set', 'anonymizeIp', true);
169 ga('send', 'pageview');