Taking advantage of a neat trick for using $ rather than a lambda
[advent-of-code-17.git] / problems / day12.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 12 - Advent of Code 2017</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?12"/>
9 <link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
10 <link rel="shortcut icon" href="/favicon.ico?2"/>
11 </head><!--
12
13
14
15
16 Oh, hello! Funny seeing you here.
17
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.
21
22 Please be careful with automated requests; I'm not Google, and I can only take
23 so much traffic. Please be considerate so that everyone gets to play.
24
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
28 all of the puzzles.
29
30 The puzzles probably took the longest; the easiest ones took an hour or two
31 each, but the harder ones took 4-5 hours, and a few even longer than that. A
32 lot of effort went into building this thing - I hope you're enjoying playing it
33 as much as I enjoyed making it for you!
34
35 If you'd like to hang out, I'm @ericwastl on Twitter.
36
37 - Eric Wastl
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 -->
89 <body>
90 <header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2017/about">[About]</a></li><li><a href="/2017/support">[AoC++]</a></li><li><a href="/2017/events">[Events]</a></li><li><a href="/2017/settings">[Settings]</a></li><li><a href="/2017/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <span class="supporter">(AoC++)</span> <span class="star-count">24*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">y(</span><a href="/2017">2017</a><span class="title-event-wrap">)</span></h1><nav><ul><li><a href="/2017">[Calendar]</a></li><li><a href="/2017/leaderboard">[Leaderboard]</a></li><li><a href="/2017/stats">[Stats]</a></li><li><a href="/2017/sponsors">[Sponsors]</a></li></ul></nav></div></header>
91
92 <div id="sidebar">
93 <div id="sponsor"><div class="quiet">Our <a href="/2017/sponsors">sponsors</a> help make Advent of Code possible:</div><p><a href="http://smartystreets.com/aoc" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);" rel="noopener">SmartyStreets</a> - U2VuZGluZyBDaH Jpc3RtYXMgY2Fy ZHMgdG8gYmFkIG FkZHJlc3Nlcz8K</p></div>
94 <div id="ad">
95 <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
96 <!-- Advent of Code Wide Skyscraper -->
97 <ins class="adsbygoogle"
98 style="display:inline-block;width:160px;height:600px"
99 data-ad-client="ca-pub-9420604735624631"
100 data-ad-slot="8014013294"></ins>
101 <script>
102 (adsbygoogle = window.adsbygoogle || []).push({});
103 </script>
104 </div><!--/ad-->
105 </div><!--/sidebar-->
106
107 <main>
108 <article class="day-desc"><h2>--- Day 12: Digital Plumber ---</h2><p>Walking along the memory banks of the stream, you find a small village that is experiencing a little confusion: some programs can't communicate with each other.</p>
109 <p>Programs in this village communicate using a fixed system of <em>pipes</em>. Messages are passed between programs using these pipes, but most programs aren't connected to each other directly. Instead, programs pass messages between each other until the message reaches the intended recipient.</p>
110 <p>For some reason, though, some of these messages aren't ever reaching their intended recipient, and the programs suspect that some <span title="Yes, citizens, plumbing! It's the latest invention to hit Rome!">pipes</span> are missing. They would like you to investigate.</p>
111 <p>You walk through the village and record the ID of each program and the IDs with which it can communicate directly (your puzzle input). Each program has one or more programs with which it can communicate, and these pipes are bidirectional; if <code>8</code> says it can communicate with <code>11</code>, then <code>11</code> will say it can communicate with <code>8</code>.</p>
112 <p>You need to figure out how many programs are in the group that contains program ID <code>0</code>.</p>
113 <p>For example, suppose you go door-to-door like a travelling salesman and record the following list:</p>
114 <pre><code>0 &lt;-&gt; 2
115 1 &lt;-&gt; 1
116 2 &lt;-&gt; 0, 3, 4
117 3 &lt;-&gt; 2, 4
118 4 &lt;-&gt; 2, 3, 6
119 5 &lt;-&gt; 6
120 6 &lt;-&gt; 4, 5
121 </code></pre>
122 <p>In this example, the following programs are in the group that contains program ID <code>0</code>:</p>
123 <ul>
124 <li>Program <code>0</code> by definition.</li>
125 <li>Program <code>2</code>, directly connected to program <code>0</code>.</li>
126 <li>Program <code>3</code> via program <code>2</code>.</li>
127 <li>Program <code>4</code> via program <code>2</code>.</li>
128 <li>Program <code>5</code> via programs <code>6</code>, then <code>4</code>, then <code>2</code>.</li>
129 <li>Program <code>6</code> via programs <code>4</code>, then <code>2</code>.</li>
130 </ul>
131 <p>Therefore, a total of <code>6</code> programs are in this group; all but program <code>1</code>, which has a pipe that connects it to itself.</p>
132 <p><em>How many programs</em> are in the group that contains program ID <code>0</code>?</p>
133 </article>
134 <p>Your puzzle answer was <code>239</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>There are more programs than just the ones in the group containing program ID <code>0</code>. The rest of them have no way of reaching that group, and still might have no way of reaching each other.</p>
135 <p>A <em>group</em> is a collection of programs that can all communicate via pipes either directly or indirectly. The programs you identified just a moment ago are all part of the same group. Now, they would like you to determine the total number of groups.</p>
136 <p>In the example above, there were <code>2</code> groups: one consisting of programs <code>0,2,3,4,5,6</code>, and the other consisting solely of program <code>1</code>.</p>
137 <p><em>How many groups are there</em> in total?</p>
138 </article>
139 <p>Your puzzle answer was <code>215</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
140 <p>At this point, you should <a href="/2017">return to your advent calendar</a> and try another puzzle.</p>
141 <p>If you still want to see it, you can <a href="12/input" target="_blank">get your puzzle input</a>.</p>
142 <p>You can also <span class="share">[Share<span class="share-content">on
143 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Digital+Plumber%22+%2D+Day+12+%2D+Advent+of+Code+2017&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F12&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
144 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F12" target="_blank">Google+</a>
145 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F12&amp;title=I%27ve+completed+%22Digital+Plumber%22+%2D+Day+12+%2D+Advent+of+Code+2017" target="_blank">Reddit</a
146 ></span>]</span> this puzzle.</p>
147 </main>
148
149 <!-- ga -->
150 <script>
151 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
152 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
153 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
154 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
155 ga('create', 'UA-69522494-1', 'auto');
156 ga('send', 'pageview');
157 </script>
158 <!-- /ga -->
159 </body>
160 </html>