Fixed typo
[advent-of-code-15.git] / advent-of-code-24.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 24 - Advent of Code</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?3"/>
9 <link rel="shortcut icon" href="/favicon.ico?2"/>
10 </head><!--
11
12
13
14
15 Oh, hello! Funny seeing you here.
16
17 I appreciate your enthusiasm, but you aren't going to find much down here.
18 There certainly aren't clues to any of the puzzles. You do risk spoiling a few
19 surprises for yourself, though. Best to play the normal way and discover
20 everything as it was intended, I think. The best surprises don't even appear
21 in the source until you unlock them for real.
22
23 Please be careful with automated requests; I'm not Google, and I can only take
24 so much traffic. Please be considerate so that everyone gets to play.
25
26 If you're curious about how Advent of Code works, it's running on some custom
27 Perl code. Other than a few integrations (auth, analytics, ads, social media),
28 I built the whole thing myself, including the design, animations, prose, and
29 all of the puzzles.
30
31 The puzzles probably took the longest; the easiest ones were around 45 minutes
32 each, but the harder ones took 2-3 hours, some even longer than that. A lot of
33 effort went into building this thing - I hope you're enjoying playing it as
34 much as I enjoyed making it for you!
35
36 If you'd like to hang out, I'm @ericwastl on Twitter.
37
38 - Eric Wastl
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 -->
90 <body>
91 <header><h1><a href="/">Advent of Code</a></h1><div class="user">Neil Smith <span class="star-count">48*</span></div><nav><ul><li><a href="/about">[About]</a></li><li><a href="/stats">[Stats]</a></li><li><a href="/leaderboard">[Leaderboard]</a></li><li><a href="/settings">[Settings]</a></li><li><a href="/auth/logout">[Log out]</a></li></ul></nav></header>
92
93 <div id="ad">
94 <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
95 <!-- Advent of Code Wide Skyscraper -->
96 <ins class="adsbygoogle"
97 style="display:inline-block;width:160px;height:600px"
98 data-ad-client="ca-pub-9420604735624631"
99 data-ad-slot="8014013294"></ins>
100 <script>
101 (adsbygoogle = window.adsbygoogle || []).push({});
102 </script>
103 </div><!--/ad-->
104
105 <main>
106 <article class="day-desc"><h2>--- Day 24: It Hangs in the Balance ---</h2><p>It's Christmas Eve, and Santa is loading up the sleigh for this year's deliveries. However, there's one small problem: he can't get the sleigh to balance. If it isn't balanced, he can't defy physics, and nobody gets presents this year.</p>
107 <p>No pressure.</p>
108 <p>Santa has provided you a list of the weights of every package he needs to fit on the sleigh. The packages need to be split into <em>three groups of exactly the same weight</em>, and every package has to fit. The first group goes in the passenger compartment of the sleigh, and the second and third go in containers on either side. Only when all three groups weigh exactly the same amount will the sleigh be able to fly. Defying physics has rules, you know!</p>
109 <p>Of course, that's not the only problem. The first group - the one going in the passenger compartment - needs <em>as few packages as possible</em> so that Santa has some legroom left over. It doesn't matter how many packages are in either of the other two groups, so long as all of the groups weigh the same.</p>
110 <p>Furthermore, Santa tells you, if there are multiple ways to arrange the packages such that the fewest possible are in the first group, you need to choose the way where the first group has <em>the smallest quantum entanglement</em> to reduce the chance of any <span title="Santa does not elaborate on what he means by this, but the cringe he makes indicates that it wouldn't be pretty.">"complications"</span>. The quantum entanglement of a group of packages is the <a href="https://en.wikipedia.org/wiki/Product_%28mathematics%29">product</a> of their weights, that is, the value you get when you multiply their weights together. Only consider quantum entanglement if the first group has the fewest possible number of packages in it and all groups weigh the same amount.</p>
111 <p>For example, suppose you have ten packages with weights <code>1</code> through <code>5</code> and <code>7</code> through <code>11</code>. For this situation, the unique first groups, their quantum entanglements, and a way to divide the remaining packages are as follows:</p>
112 <pre><code>Group 1; Group 2; Group 3
113 11 9 (QE= 99); 10 8 2; 7 5 4 3 1
114 10 9 1 (QE= 90); 11 7 2; 8 5 4 3
115 10 8 2 (QE=160); 11 9; 7 5 4 3 1
116 10 7 3 (QE=210); 11 9; 8 5 4 2 1
117 10 5 4 1 (QE=200); 11 9; 8 7 3 2
118 10 5 3 2 (QE=300); 11 9; 8 7 4 1
119 10 4 3 2 1 (QE=240); 11 9; 8 7 5
120 9 8 3 (QE=216); 11 7 2; 10 5 4 1
121 9 7 4 (QE=252); 11 8 1; 10 5 3 2
122 9 5 4 2 (QE=360); 11 8 1; 10 7 3
123 8 7 5 (QE=280); 11 9; 10 4 3 2 1
124 8 5 4 3 (QE=480); 11 9; 10 7 2 1
125 7 5 4 3 1 (QE=420); 11 9; 10 8 2
126 </code></pre>
127 <p>Of these, although <code>10 9 1</code> has the smallest quantum entanglement (<code>90</code>), the configuration with only two packages, <code>11 9</code>, in the passenger compartment gives Santa the most legroom and wins. In this situation, the quantum entanglement for the ideal configuration is therefore <code>99</code>. Had there been two configurations with only two packages in the first group, the one with the smaller quantum entanglement would be chosen.</p>
128 <p>What is the <em>quantum entanglement</em> of the first group of packages in the ideal configuration?</p>
129 </article>
130 <p>Your puzzle answer was <code>10723906903</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>That's weird... the sleigh still isn't balancing.</p>
131 <p>"Ho ho ho", Santa muses to himself. "I forgot the trunk".</p>
132 <p>Balance the sleigh again, but this time, separate the packages into <em>four groups</em> instead of three. The other constraints still apply.</p>
133 <p>Given the example packages above, this would be the new unique first groups, their quantum entanglements, and one way to divide the remaining packages:</p>
134 <pre><code>
135 11 4 (QE=44); 10 5; 9 3 2 1; 8 7
136 10 5 (QE=50); 11 4; 9 3 2 1; 8 7
137 9 5 1 (QE=45); 11 4; 10 3 2; 8 7
138 9 4 2 (QE=72); 11 3 1; 10 5; 8 7
139 9 3 2 1 (QE=54); 11 4; 10 5; 8 7
140 8 7 (QE=56); 11 4; 10 5; 9 3 2 1
141 </code></pre>
142 <p>Of these, there are three arrangements that put the minimum (two) number of packages in the first group: <code>11 4</code>, <code>10 5</code>, and <code>8 7</code>. Of these, <code>11 4</code> has the lowest quantum entanglement, and so it is selected.</p>
143 <p>Now, what is the <em>quantum entanglement</em> of the first group of packages in the ideal configuration?</p>
144 </article>
145 <p>Your puzzle answer was <code>74850409</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
146 <p>At this point, you should <a href="/">return to your advent calendar</a> and try another puzzle.</p>
147 <p>If you still want to see it, you can <a href="/day/24/input" target="_blank">get your puzzle input</a>.</p>
148 <p>You can also <span class="share">[Share<span class="share-content">on
149 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
150 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24" target="_blank">Google+</a>
151 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2Fday%2F24&amp;title=I%27ve+completed+%22It+Hangs+in+the+Balance%22+%2D+Day+24+%2D+Advent+of+Code" target="_blank">Reddit</a
152 ></span>]</span>
153 this puzzle.</p>
154 </main>
155
156 <!-- ga -->
157 <script>
158 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
159 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
160 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
161 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
162 ga('create', 'UA-69522494-1', 'auto');
163 ga('send', 'pageview');
164 </script>
165 <!-- /ga -->
166 </body>
167 </html>