Taking advantage of a neat trick for using $ rather than a lambda
[advent-of-code-17.git] / problems / day24.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 24 - 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">48*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">0xffff&amp;</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://winton.com/" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);" rel="noopener">Winton</a> - a data science and investment management company</p></div>
94 <p class="quiet">By popular demand, there are now AoC-themed objects available (until Jan. 3rd)! Get them shipped <a href="https://teespring.com/advent-of-code" target="_blank">from the US</a> or <a href="https://teespring.com/advent-of-code-eu" target="_blank">from Europe</a>.</p>
95
96 </div><!--/sidebar-->
97
98 <main>
99 <article class="day-desc"><h2>--- Day 24: Electromagnetic Moat ---</h2><p>The CPU itself is a large, black building surrounded by a bottomless pit. Enormous metal tubes extend outward from the side of the building at regular intervals and descend down into the void. There's no way to cross, but you need to get inside.</p>
100 <p>No way, of course, other than building a <em>bridge</em> out of the magnetic components strewn about nearby.</p>
101 <p>Each component has two <em>ports</em>, one on each end. The ports come in all different types, and only matching types can be connected. You take an inventory of the components by their port types (your puzzle input). Each port is identified by the number of <em>pins</em> it uses; more pins mean a stronger connection for your bridge. A <code>3/7</code> component, for example, has a type-<code>3</code> port on one side, and a type-<code>7</code> port on the other.</p>
102 <p>Your side of the pit is metallic; a perfect surface to connect a magnetic, <em>zero-pin port</em>. Because of this, the first port you use must be of type <code>0</code>. It doesn't matter what type of port you end with; your goal is just to make the bridge as strong as possible.</p>
103 <p>The <em>strength</em> of a bridge is the sum of the port types in each component. For example, if your bridge is made of components <code>0/3</code>, <code>3/7</code>, and <code>7/4</code>, your bridge has a strength of <code>0+3 + 3+7 + 7+4 = 24</code>.</p>
104 <p>For example, suppose you had the following components:</p>
105 <pre><code>0/2
106 2/2
107 2/3
108 3/4
109 3/5
110 0/1
111 10/1
112 9/10
113 </code></pre>
114 <p>With them, you could make the following valid bridges:</p>
115 <ul>
116 <li><code>0/1</code></li>
117 <li><code>0/1</code>--<code>10/1</code></li>
118 <li><code>0/1</code>--<code>10/1</code>--<code>9/10</code></li>
119 <li><code>0/2</code></li>
120 <li><code>0/2</code>--<code>2/3</code></li>
121 <li><code>0/2</code>--<code>2/3</code>--<code>3/4</code></li>
122 <li><code>0/2</code>--<code>2/3</code>--<code>3/5</code></li>
123 <li><code>0/2</code>--<code>2/2</code></li>
124 <li><code>0/2</code>--<code>2/2</code>--<code>2/3</code></li>
125 <li><code>0/2</code>--<code>2/2</code>--<code>2/3</code>--<code>3/4</code></li>
126 <li><code>0/2</code>--<code>2/2</code>--<code>2/3</code>--<code>3/5</code></li>
127 </ul>
128 <p>(Note how, as shown by <code>10/1</code>, order of ports within a component doesn't matter. However, you may only use each port on a component once.)</p>
129 <p>Of these bridges, the <em>strongest</em> one is <code>0/1</code>--<code>10/1</code>--<code>9/10</code>; it has a strength of <code>0+1 + 1+10 + 10+9 = <em>31</em></code>.</p>
130 <p><em>What is the strength of the strongest bridge you can make</em> with the components you have available?</p>
131 </article>
132 <p>Your puzzle answer was <code>1940</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>The bridge you've built isn't long enough; you can't <span title="Who do you think you are, Mario?">jump the rest of the way</span>.</p>
133 <p>In the example above, there are two longest bridges:</p>
134 <ul>
135 <li><code>0/2</code>--<code>2/2</code>--<code>2/3</code>--<code>3/4</code></li>
136 <li><code>0/2</code>--<code>2/2</code>--<code>2/3</code>--<code>3/5</code></li>
137 </ul>
138 <p>Of them, the one which uses the <code>3/5</code> component is stronger; its strength is <code>0+2 + 2+2 + 2+3 + 3+5 = <em>19</em></code>.</p>
139 <p><em>What is the strength of the longest bridge you can make?</em> If you can make multiple bridges of the longest length, pick the <em>strongest</em> one.</p>
140 </article>
141 <p>Your puzzle answer was <code>1928</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
142 <p>At this point, you should <a href="/2017">return to your advent calendar</a> and try another puzzle.</p>
143 <p>If you still want to see it, you can <a href="24/input" target="_blank">get your puzzle input</a>.</p>
144 <p>You can also <span class="share">[Share<span class="share-content">on
145 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Electromagnetic+Moat%22+%2D+Day+24+%2D+Advent+of+Code+2017&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F24&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
146 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F24" target="_blank">Google+</a>
147 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2017%2Fday%2F24&amp;title=I%27ve+completed+%22Electromagnetic+Moat%22+%2D+Day+24+%2D+Advent+of+Code+2017" target="_blank">Reddit</a
148 ></span>]</span> this puzzle.</p>
149 </main>
150
151 <!-- ga -->
152 <script>
153 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
154 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
155 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
156 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
157 ga('create', 'UA-69522494-1', 'auto');
158 ga('send', 'pageview');
159 </script>
160 <!-- /ga -->
161 </body>
162 </html>