4 <meta charset=
"utf-8"/>
5 <title>Day
11 - Advent of Code
2021</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?26"/>
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, social media), I
27 built the whole thing myself, including the design, animations, prose, and all
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=
"/2021/about">[About]
</a></li><li><a href=
"/2021/events">[Events]
</a></li><li><a href=
"https://teespring.com/stores/advent-of-code" target=
"_blank">[Shop]
</a></li><li><a href=
"/2021/settings">[Settings]
</a></li><li><a href=
"/2021/auth/logout">[Log Out]
</a></li></ul></nav><div class=
"user">Neil Smith
<a href=
"/2021/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">{
'year
':
</span><a href=
"/2021">2021</a><span class=
"title-event-wrap">}
</span></h1><nav><ul><li><a href=
"/2021">[Calendar]
</a></li><li><a href=
"/2021/support">[AoC++]
</a></li><li><a href=
"/2021/sponsors">[Sponsors]
</a></li><li><a href=
"/2021/leaderboard">[Leaderboard]
</a></li><li><a href=
"/2021/stats">[Stats]
</a></li></ul></nav></div></header>
93 <div id=
"sponsor"><div class=
"quiet">Our
<a href=
"/2021/sponsors">sponsors
</a> help make Advent of Code possible:
</div><div class=
"sponsor"><a href=
"https://2021-aoc-templates.util.repl.co/" target=
"_blank" onclick=
"if(ga)ga('send','event','sponsor','sidebar',this.href);" rel=
"noopener">Replit
</a> - Code and host in your browser with no setup in Python, React, Kaboom.js, Java, C, Nix, you name it, even Solidity. Happy coding!
</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: Dumbo Octopus ---
</h2><p>You enter a large cavern full of rare bioluminescent
<a href=
"https://www.youtube.com/watch?v=eih-VSaS2g0" target=
"_blank">dumbo octopuses
</a>! They seem to not like the Christmas lights on your submarine, so you turn them off for now.
</p>
99 <p>There are
100 <span title=
"I know it's weird; I grew up saying 'octopi' too.">octopuses
</span> arranged neatly in a
10 by
10 grid. Each octopus slowly gains
<em>energy
</em> over time and
<em>flashes
</em> brightly for a moment when its energy is full. Although your lights are off, maybe you could navigate through the cave without disturbing the octopuses if you could predict when the flashes of light will happen.
</p>
100 <p>Each octopus has an
<em>energy level
</em> - your submarine can remotely measure the energy level of each octopus (your puzzle input). For example:
</p>
101 <pre><code>5483143223
112 <p>The energy level of each octopus is a value between
<code>0</code> and
<code>9</code>. Here, the top-left octopus has an energy level of
<code>5</code>, the bottom-right one has an energy level of
<code>6</code>, and so on.
</p>
113 <p>You can model the energy levels and flashes of light in
<em>steps
</em>. During a single step, the following occurs:
</p>
115 <li>First, the energy level of each octopus increases by
<code>1</code>.
</li>
116 <li>Then, any octopus with an energy level greater than
<code>9</code> <em>flashes
</em>. This increases the energy level of all adjacent octopuses by
<code>1</code>, including octopuses that are diagonally adjacent. If this causes an octopus to have an energy level greater than
<code>9</code>, it
<em>also flashes
</em>. This process continues as long as new octopuses keep having their energy level increased beyond
<code>9</code>. (An octopus can only flash
<em>at most once per step
</em>.)
</li>
117 <li>Finally, any octopus that flashed during this step has its energy level set to
<code>0</code>, as it used all of its energy to flash.
</li>
119 <p>Adjacent flashes can cause an octopus to flash on a step even if it begins that step with very little energy. Consider the middle octopus with
<code>1</code> energy in this situation:
</p>
120 <pre><code>Before any steps:
141 <p>An octopus is
<em>highlighted
</em> when it flashed during the given step.
</p>
142 <p>Here is how the larger example above progresses:
</p>
143 <pre><code>Before any steps:
169 5<em>0</em>89<em>0</em>87<em>0</em>54
172 87<em>00</em>9<em>0</em>88<em>00</em>
180 <em>00</em>5<em>0</em>9<em>00</em>866
181 85<em>00</em>8<em>00</em>575
184 9935<em>0</em>8<em>00</em>63
188 <em>0</em>421125<em>000</em>
189 <em>00</em>21119<em>000</em>
193 <em>0</em>923<em>0</em>31697
194 <em>00</em>3222115<em>0</em>
198 <em>00</em>4236112<em>0</em>
205 2<em>0</em>44144<em>000</em>
232 35<em>00</em>6256<em>0</em>9
243 46<em>0</em>876683<em>0</em>
252 9<em>0</em>6<em>0000</em>644
254 69<em>000000</em>8<em>0</em>
258 8<em>0</em>2125<em>000</em>9
265 <em>00</em>31112<em>00</em>9
266 <em>00</em>411125<em>0</em>4
267 <em>00</em>811114<em>0</em>6
268 <em>00</em>991113<em>0</em>6
270 <em>0</em>44236113<em>0</em>
272 <em>0</em>53225<em>0</em>6<em>00</em>
273 <em>00</em>3224<em>0000</em>
276 <p>After step
10, there have been a total of
<code>204</code> flashes. Fast forwarding, here is the same configuration every
10 steps:
</p>
278 <pre><code>After step
20:
355 457<em>0</em>86557<em>0</em>
358 <em>0000000</em>99<em>0</em>
359 <em>0000000</em>8<em>00</em>
386 <p>After
100 steps, there have been a total of
<code><em>1656</em></code> flashes.
</p>
387 <p>Given the starting energy levels of the dumbo octopuses in your cavern, simulate
100 steps.
<em>How many total flashes are there after
100 steps?
</em></p>
389 <p>Your puzzle answer was
<code>1627</code>.
</p><article class=
"day-desc"><h2 id=
"part2">--- Part Two ---
</h2><p>It seems like the individual flashes aren't bright enough to navigate. However, you might have a better option: the flashes seem to be
<em>synchronizing
</em>!
</p>
390 <p>In the example above, the first time all octopuses flash simultaneously is step
<code><em>195</em></code>:
</p>
391 <pre><code>After step
193:
427 <p>If you can calculate the exact moments when the octopuses will all flash simultaneously, you should be able to navigate through the cavern.
<em>What is the first step during which all octopuses flash?
</em></p>
429 <p>Your puzzle answer was
<code>329</code>.
</p><p class=
"day-success">Both parts of this puzzle are complete! They provide two gold stars: **
</p>
430 <p>At this point, you should
<a href=
"/2021">return to your Advent calendar
</a> and try another puzzle.
</p>
431 <p>If you still want to see it, you can
<a href=
"11/input" target=
"_blank">get your puzzle input
</a>.
</p>
432 <p>You can also
<span class=
"share">[Share
<span class=
"share-content">on
433 <a href=
"https://twitter.com/intent/tweet?text=I%27ve+completed+%22Dumbo+Octopus%22+%2D+Day+11+%2D+Advent+of+Code+2021&url=https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F11&related=ericwastl&hashtags=AdventOfCode" target=
"_blank">Twitter
</a>
434 <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+%22Dumbo+Octopus%22+%2D+Day+11+%2D+Advent+of+Code+2021+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2021%2Fday%2F11'}else{return false;}" target=
"_blank">Mastodon
</a
435 ></span>]
</span> this puzzle.
</p>
440 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
441 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=
1*new Date();a=s.createElement(o),
442 m=s.getElementsByTagName(o)[
0];a.async=
1;a.src=g;m.parentNode.insertBefore(a,m)
443 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
444 ga('create', 'UA-
69522494-
1', 'auto');
445 ga('set', 'anonymizeIp', true);
446 ga('send', 'pageview');