-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday21.html
73 lines (70 loc) · 5.51 KB
/
day21.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
<html>
<head>
<link href='//fonts.googleapis.com/css?family=Source+Code+Pro:300&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="../assets/application.css" />
<link rel="stylesheet" type="text/css" href="../assets/easter-egg.css" />
<link rel="shortcut icon" href="../assets/favicon.png" />
</head>
<body>
<header>
<div>
<h1 class="title-global"><a href="https://adventofcode.com/2020" target="_blank">Advent of Code</a></h1>
<div class="user">John Dugan</div>
</div>
<div>
<h1 class="title-event"> <span class="title-event-wrap">{year=></span><a href="https://adventofcode.com/2020" target="_blank">2020</a><span class="title-event-wrap">}</span></h1>
<nav>
<ul>
<li><a href="index.html">[Calendar]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/private/view/251766" target="_blank">[Memphis]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/private/view/371961" target="_blank">[Oslo]</a></li>
<li><a href="https://adventofcode.com/2020/leaderboard/self" target="_blank">[Personal Stats]</a></li>
<li><a href="https://adventofcode.com/2020/stats" target="_blank">[Stats]</a></li>
</ul>
</nav>
</div>
</header>
<main>
<article class="day-desc">
<h2>--- Day 21: Allergen Assessment ---</h2>
<p>You reach the train's last stop and the closest you can get to your vacation island without getting wet. There aren't even any boats here, but nothing can stop you now: you build a raft. You just need a few days' worth of food for your
journey.</p>
<p>You don't speak the local language, so you can't read any ingredients lists. However, sometimes, allergens are listed in a language you <em>do</em> understand. You should be able to use this information to determine which ingredient
contains which allergen and <span title="I actually considered doing this once. I do not recommend it.">work out which foods are safe</span> to take with you on your trip.</p>
<p>You start by compiling a list of foods (your puzzle input), one food per line. Each line includes that food's <em>ingredients list</em> followed by some or all of the allergens the food contains.</p>
<p>Each allergen is found in exactly one ingredient. Each ingredient contains zero or one allergen. <em>Allergens aren't always marked</em>; when they're listed (as in <code>(contains nuts, shellfish)</code> after an ingredients list), the
ingredient that contains each listed allergen will be <em>somewhere in the corresponding ingredients list</em>. However, even if an allergen isn't listed, the ingredient that contains that allergen could still be present: maybe they forgot
to label it, or maybe it was labeled in a language you don't know.</p>
<p>For example, consider the following list of foods:</p>
<pre><code>mxmxvkd kfcds sqjhc nhms (contains dairy, fish)
trh fvjkl sbzzf mxmxvkd (contains dairy)
sqjhc fvjkl (contains soy)
sqjhc mxmxvkd sbzzf (contains fish)
</code></pre>
<p>The first food in the list has four ingredients (written in a language you don't understand): <code>mxmxvkd</code>, <code>kfcds</code>, <code>sqjhc</code>, and <code>nhms</code>. While the food might contain other allergens, a few allergens
the food definitely contains are listed afterward: <code>dairy</code> and <code>fish</code>.</p>
<p>The first step is to determine which ingredients <em>can't possibly</em> contain any of the allergens in any food in your list. In the above example, none of the ingredients <code>kfcds</code>, <code>nhms</code>, <code>sbzzf</code>, or
<code>trh</code> can contain an allergen. Counting the number of times any of these ingredients appear in any ingredients list produces <em><code>5</code></em>: they all appear once each except <code>sbzzf</code>, which appears twice.</p>
<p>Determine which ingredients cannot possibly contain any of the allergens in your list. <em>How many times do any of those ingredients appear?</em></p>
</article>
<p>Your puzzle answer was <code>2374</code>.</p>
<article class="day-desc">
<h2 id="part2">--- Part Two ---</h2>
<p>Now that you've isolated the inert ingredients, you should have enough information to figure out which ingredient contains which allergen.</p>
<p>In the above example:</p>
<ul>
<li><code>mxmxvkd</code> contains <code>dairy</code>.</li>
<li><code>sqjhc</code> contains <code>fish</code>.</li>
<li><code>fvjkl</code> contains <code>soy</code>.</li>
</ul>
<p>Arrange the ingredients <em>alphabetically by their allergen</em> and separate them by commas to produce your <em>canonical dangerous ingredient list</em>. (There should <em>not be any spaces</em> in your canonical dangerous ingredient
list.) In the above example, this would be <em><code>mxmxvkd,sqjhc,fvjkl</code></em>.</p>
<p>Time to stock your raft with supplies. <em>What is your canonical dangerous ingredient list?</em></p>
</article>
<p>Your puzzle answer was <code>fbtqkzc,jbbsjh,cpttmnv,ccrbr,tdmqcl,vnjxjg,nlph,mzqjxq</code>.</p>
<p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, you should <a href="index.html">return to your Advent calendar</a> and try another puzzle.</p>
<p>If you still want to see it, you can <a href="../data/day21/input.txt" target="_blank">get your puzzle input</a>.</p>
</main>
</body>
</html>