4 <meta charset=
"utf-8"/>
5 <title>Day
2 - Advent of Code
2023</title>
6 <link rel=
"stylesheet" type=
"text/css" href=
"/static/style.css?31"/>
7 <link rel=
"stylesheet alternate" type=
"text/css" href=
"/static/highcontrast.css?1" title=
"High Contrast"/>
8 <link rel=
"shortcut icon" href=
"/favicon.png"/>
9 <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>
15 Oh, hello! Funny seeing you here.
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. The best surprises don't
19 even appear in the source until you unlock them for real.
21 Please be careful with automated requests; I'm not a massive company, and I can
22 only take so much traffic. Please be considerate so that everyone gets to play.
24 If you're curious about how Advent of Code works, it's running on some custom
25 Perl code. Other than a few integrations (auth, analytics, social media), I
26 built the whole thing myself, including the design, animations, prose, and all
29 The puzzles are most of the work; preparing a new calendar and a new set of
30 puzzles each year takes all of my free time for 4-5 months. A lot of effort
31 went into building this thing - I hope you're enjoying playing it as much as I
32 enjoyed making it for you!
34 If you'd like to hang out, I'm @ericwastl@hachyderm.io on Mastodon and
35 @ericwastl on Twitter.
90 <header><div><h1 class=
"title-global"><a href=
"/">Advent of Code
</a></h1><nav><ul><li><a href=
"/2023/about">[About]
</a></li><li><a href=
"/2023/events">[Events]
</a></li><li><a href=
"https://teespring.com/stores/advent-of-code" target=
"_blank">[Shop]
</a></li><li><a href=
"/2023/settings">[Settings]
</a></li><li><a href=
"/2023/auth/logout">[Log Out]
</a></li></ul></nav><div class=
"user">Neil Smith
<a href=
"/2023/support" class=
"supporter-badge" title=
"Advent of Code Supporter">(AoC++)
</a> <span class=
"star-count">4*
</span></div></div><div><h1 class=
"title-event"> <span class=
"title-event-wrap"></span><a href=
"/2023">2023</a><span class=
"title-event-wrap"></span></h1><nav><ul><li><a href=
"/2023">[Calendar]
</a></li><li><a href=
"/2023/support">[AoC++]
</a></li><li><a href=
"/2023/sponsors">[Sponsors]
</a></li><li><a href=
"/2023/leaderboard">[Leaderboard]
</a></li><li><a href=
"/2023/stats">[Stats]
</a></li></ul></nav></div></header>
93 <div id=
"sponsor"><div class=
"quiet">Our
<a href=
"/2023/sponsors">sponsors
</a> help make Advent of Code possible:
</div><div class=
"sponsor"><a href=
"https://www.catawiki.com/en/p/917-catawiki-advent-of-code-2023-raffle" target=
"_blank" onclick=
"if(ga)ga('send','event','sponsor','sidebar',this.href);" rel=
"noopener">Catawiki
</a> - Turn your passion into your career. Join us! bit.ly/join-cw
</div></div>
97 <article class=
"day-desc"><h2>--- Day
2: Cube Conundrum ---
</h2><p>You're launched high into the atmosphere! The apex of your trajectory just barely reaches the surface of a large island floating in the sky. You gently land in a fluffy pile of leaves. It's quite cold, but you don't see much snow. An Elf runs over to greet you.
</p>
98 <p>The Elf explains that you've arrived at
<em>Snow Island
</em> and apologizes for the lack of snow. He'll be happy to explain the situation, but it's a bit of a walk, so you have some time. They don't get many visitors up here;
<span title=
"No, the Elf's name is not 'WOPR'. It's Joshua.">would you like to play a game
</span> in the meantime?
</p>
99 <p>As you walk, the Elf shows you a small bag and some cubes which are either red, green, or blue. Each time you play this game, he will hide a secret number of cubes of each color in the bag, and your goal is to figure out information about the number of cubes.
</p>
100 <p>To get information, once a bag has been loaded with cubes, the Elf will reach into the bag, grab a handful of random cubes, show them to you, and then put them back in the bag. He'll do this a few times per game.
</p>
101 <p>You play several games and record the information from each game (your puzzle input). Each game is listed with its ID number (like the
<code>11</code> in
<code>Game
11: ...
</code>) followed by a semicolon-separated list of subsets of cubes that were revealed from the bag (like
<code>3 red,
5 green,
4 blue
</code>).
</p>
102 <p>For example, the record of a few games might look like this:
</p>
103 <pre><code>Game
1:
3 blue,
4 red;
1 red,
2 green,
6 blue;
2 green
104 Game
2:
1 blue,
2 green;
3 green,
4 blue,
1 red;
1 green,
1 blue
105 Game
3:
8 green,
6 blue,
20 red;
5 blue,
4 red,
13 green;
5 green,
1 red
106 Game
4:
1 green,
3 red,
6 blue;
3 green,
6 red;
3 green,
15 blue,
14 red
107 Game
5:
6 red,
1 blue,
3 green;
2 blue,
1 red,
2 green
109 <p>In game
1, three sets of cubes are revealed from the bag (and then put back again). The first set is
3 blue cubes and
4 red cubes; the second set is
1 red cube,
2 green cubes, and
6 blue cubes; the third set is only
2 green cubes.
</p>
110 <p>The Elf would first like to know which games would have been possible if the bag contained
<em>only
12 red cubes,
13 green cubes, and
14 blue cubes
</em>?
</p>
111 <p>In the example above, games
1,
2, and
5 would have been
<em>possible
</em> if the bag had been loaded with that configuration. However, game
3 would have been
<em>impossible
</em> because at one point the Elf showed you
20 red cubes at once; similarly, game
4 would also have been
<em>impossible
</em> because the Elf showed you
15 blue cubes at once. If you add up the IDs of the games that would have been possible, you get
<code><em>8</em></code>.
</p>
112 <p>Determine which games would have been possible if the bag had been loaded with only
12 red cubes,
13 green cubes, and
14 blue cubes.
<em>What is the sum of the IDs of those games?
</em></p>
114 <p>Your puzzle answer was
<code>2101</code>.
</p><article class=
"day-desc"><h2 id=
"part2">--- Part Two ---
</h2><p>The Elf says they've stopped producing snow because they aren't getting any
<em>water
</em>! He isn't sure why the water stopped; however, he can show you how to get to the water source to check it out for yourself. It's just up ahead!
</p>
115 <p>As you continue your walk, the Elf poses a second question: in each game you played, what is the
<em>fewest number of cubes of each color
</em> that could have been in the bag to make the game possible?
</p>
116 <p>Again consider the example games from earlier:
</p>
117 <pre><code>Game
1:
3 blue,
4 red;
1 red,
2 green,
6 blue;
2 green
118 Game
2:
1 blue,
2 green;
3 green,
4 blue,
1 red;
1 green,
1 blue
119 Game
3:
8 green,
6 blue,
20 red;
5 blue,
4 red,
13 green;
5 green,
1 red
120 Game
4:
1 green,
3 red,
6 blue;
3 green,
6 red;
3 green,
15 blue,
14 red
121 Game
5:
6 red,
1 blue,
3 green;
2 blue,
1 red,
2 green
124 <li>In game
1, the game could have been played with as few as
4 red,
2 green, and
6 blue cubes. If any color had even one fewer cube, the game would have been impossible.
</li>
125 <li>Game
2 could have been played with a minimum of
1 red,
3 green, and
4 blue cubes.
<li>
126 <li>Game
3 must have been played with at least
20 red,
13 green, and
6 blue cubes.
</li>
127 <li>Game
4 required at least
14 red,
3 green, and
15 blue cubes.
</li>
128 <li>Game
5 needed no fewer than
6 red,
3 green, and
2 blue cubes in the bag.
</li>
130 <p>The
<em>power
</em> of a set of cubes is equal to the numbers of red, green, and blue cubes multiplied together. The power of the minimum set of cubes in game
1 is
<code>48</code>. In games
2-
5 it was
<code>12</code>,
<code>1560</code>,
<code>630</code>, and
<code>36</code>, respectively. Adding up these five powers produces the sum
<code><em>2286</em></code>.
</p>
131 <p>For each game, find the minimum set of cubes that must have been present.
<em>What is the sum of the power of these sets?
</em></p>
133 <p>Your puzzle answer was
<code>58269</code>.
</p><p class=
"day-success">Both parts of this puzzle are complete! They provide two gold stars: **
</p>
134 <p>At this point, you should
<a href=
"/2023">return to your Advent calendar
</a> and try another puzzle.
</p>
135 <p>If you still want to see it, you can
<a href=
"2/input" target=
"_blank">get your puzzle input
</a>.
</p>
136 <p>You can also
<span class=
"share">[Share
<span class=
"share-content">on
137 <a href=
"https://twitter.com/intent/tweet?text=I%27ve+completed+%22Cube+Conundrum%22+%2D+Day+2+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F2&related=ericwastl&hashtags=AdventOfCode" target=
"_blank">Twitter
</a>
138 <a href=
"javascript:void(0);" onclick=
"var ms; try{ms=localStorage.getItem('mastodon.server')}finally{} if(typeof ms!=='string')ms=''; ms=prompt('Mastodon Server?',ms); if(typeof ms==='string' && ms.length){this.href='https://'+ms+'/share?text=I%27ve+completed+%22Cube+Conundrum%22+%2D+Day+2+%2D+Advent+of+Code+2023+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F2';try{localStorage.setItem('mastodon.server',ms);}finally{}}else{return false;}" target=
"_blank">Mastodon
</a
139 ></span>]
</span> this puzzle.
</p>
144 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
145 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=
1*new Date();a=s.createElement(o),
146 m=s.getElementsByTagName(o)[
0];a.async=
1;a.src=g;m.parentNode.insertBefore(a,m)
147 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
148 ga('create', 'UA-
69522494-
1', 'auto');
149 ga('set', 'anonymizeIp', true);
150 ga('send', 'pageview');