Split datafile finding into a library
[advent-of-code-22.git] / problems / day01.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 1 - Advent of Code 2022</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?30"/>
9 <link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
10 <link rel="shortcut icon" href="/favicon.png"/>
11 <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>
12 </head><!--
13
14
15
16
17 Oh, hello! Funny seeing you here.
18
19 I appreciate your enthusiasm, but you aren't going to find much down here.
20 There certainly aren't clues to any of the puzzles. The best surprises don't
21 even appear in the source until you unlock them for real.
22
23 Please be careful with automated requests; I'm not a massive company, and I can
24 only take 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, social media), I
28 built the whole thing myself, including the design, animations, prose, and all
29 of the puzzles.
30
31 The puzzles are most of the work; preparing a new calendar and a new set of
32 puzzles each year takes all of my free time for 4-5 months. A lot of effort
33 went into building this thing - I hope you're enjoying playing it as much as I
34 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><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2022/about">[About]</a></li><li><a href="/2022/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2022/settings">[Settings]</a></li><li><a href="/2022/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <a href="/2022/support" class="supporter-badge" title="Advent of Code Supporter">(AoC++)</a> <span class="star-count">2*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">$year=</span><a href="/2022">2022</a><span class="title-event-wrap">;</span></h1><nav><ul><li><a href="/2022">[Calendar]</a></li><li><a href="/2022/support">[AoC++]</a></li><li><a href="/2022/sponsors">[Sponsors]</a></li><li><a href="/2022/leaderboard">[Leaderboard]</a></li><li><a href="/2022/stats">[Stats]</a></li></ul></nav></div></header>
92
93 <div id="sidebar">
94 <div id="sponsor"><div class="quiet">Our <a href="/2022/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://ntropy.com/" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">Ntropy</a> - The Ntropy API enables companies to build a new generation of products and services on top of financial transaction data.</div></div>
95 </div><!--/sidebar-->
96
97 <main>
98 <article class="day-desc"><h2>--- Day 1: Calorie Counting ---</h2><p>Santa's reindeer typically eat regular reindeer food, but they need a lot of <a href="/2018/day/25">magical energy</a> to deliver presents on Christmas. For that, their favorite snack is a special type of <em class="star">star</em> fruit that only grows deep in the jungle. The Elves have brought you on their annual expedition to the grove where the fruit grows.</p>
99 <p>To supply enough magical energy, the expedition needs to retrieve a minimum of <em class="star">fifty stars</em> by December 25th. Although the Elves assure you that the grove has plenty of fruit, you decide to grab any fruit you see along the way, just in case.</p>
100 <p>Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants <em class="star">one star</em>. Good luck!</p>
101 <p>The jungle must be too overgrown and difficult to navigate in vehicles or access from the air; the Elves' expedition traditionally goes on foot. As your boats approach land, the Elves begin taking inventory of their supplies. One important consideration is food - in particular, the number of <em>Calories</em> each Elf is carrying (your puzzle input).</p>
102 <p>The Elves take turns writing down the number of Calories contained by the various meals, snacks, rations, <span title="By &quot;etc&quot;, you're pretty sure they just mean &quot;more snacks&quot;.">etc.</span> that they've brought with them, one item per line. Each Elf separates their own inventory from the previous Elf's inventory (if any) by a blank line.</p>
103 <p>For example, suppose the Elves finish writing their items' Calories and end up with the following list:</p>
104 <pre><code>1000
105 2000
106 3000
107
108 4000
109
110 5000
111 6000
112
113 7000
114 8000
115 9000
116
117 10000
118 </code></pre>
119 <p>This list represents the Calories of the food carried by five Elves:</p>
120 <ul>
121 <li>The first Elf is carrying food with <code>1000</code>, <code>2000</code>, and <code>3000</code> Calories, a total of <code><em>6000</em></code> Calories.</li>
122 <li>The second Elf is carrying one food item with <code><em>4000</em></code> Calories.</li>
123 <li>The third Elf is carrying food with <code>5000</code> and <code>6000</code> Calories, a total of <code><em>11000</em></code> Calories.</li>
124 <li>The fourth Elf is carrying food with <code>7000</code>, <code>8000</code>, and <code>9000</code> Calories, a total of <code><em>24000</em></code> Calories.</li>
125 <li>The fifth Elf is carrying one food item with <code><em>10000</em></code> Calories.</li>
126 </ul>
127 <p>In case the Elves get hungry and need extra snacks, they need to know which Elf to ask: they'd like to know how many Calories are being carried by the Elf carrying the <em>most</em> Calories. In the example above, this is <em><code>24000</code></em> (carried by the fourth Elf).</p>
128 <p>Find the Elf carrying the most Calories. <em>How many total Calories is that Elf carrying?</em></p>
129 </article>
130 <p>Your puzzle answer was <code>66719</code>.</p><article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p>By the time you calculate the answer to the Elves' question, they've already realized that the Elf carrying the most Calories of food might eventually <em>run out of snacks</em>.</p>
131 <p>To avoid this unacceptable situation, the Elves would instead like to know the total Calories carried by the <em>top three</em> Elves carrying the most Calories. That way, even if one of those Elves runs out of snacks, they still have two backups.</p>
132 <p>In the example above, the top three Elves are the fourth Elf (with <code>24000</code> Calories), then the third Elf (with <code>11000</code> Calories), then the fifth Elf (with <code>10000</codE> Calories). The sum of the Calories carried by these three elves is <code><em>45000</em></code>.</p>
133 <p>Find the top three Elves carrying the most Calories. <em>How many Calories are those Elves carrying in total?</em></p>
134 </article>
135 <p>Your puzzle answer was <code>198551</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
136 <p>At this point, you should <a href="/2022">return to your Advent calendar</a> and try another puzzle.</p>
137 <p>If you still want to see it, you can <a href="1/input" target="_blank">get your puzzle input</a>.</p>
138 <p>You can also <span class="share">[Share<span class="share-content">on
139 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Calorie+Counting%22+%2D+Day+1+%2D+Advent+of+Code+2022&amp;url=https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F1&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
140 <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+%22Calorie+Counting%22+%2D+Day+1+%2D+Advent+of+Code+2022+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2022%2Fday%2F1'}else{return false;}" target="_blank">Mastodon</a
141 ></span>]</span> this puzzle.</p>
142 </main>
143
144 <!-- ga -->
145 <script>
146 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
147 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
148 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
149 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
150 ga('create', 'UA-69522494-1', 'auto');
151 ga('set', 'anonymizeIp', true);
152 ga('send', 'pageview');
153 </script>
154 <!-- /ga -->
155 </body>
156 </html>