-
Notifications
You must be signed in to change notification settings - Fork 0
/
year2024_day25_puzzle.html
215 lines (148 loc) · 9.82 KB
/
year2024_day25_puzzle.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8"/>
<title>Day 25 - Advent of Code 2024</title>
<link rel="stylesheet" type="text/css" href="/static/style.css?31"/>
<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?1" title="High Contrast"/>
<link rel="shortcut icon" href="/favicon.png"/>
<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>
</head><!--
Oh, hello! Funny seeing you here.
I appreciate your enthusiasm, but you aren't going to find much down here.
There certainly aren't clues to any of the puzzles. The best surprises don't
even appear in the source until you unlock them for real.
Please be careful with automated requests; I'm not a massive company, and I can
only take so much traffic. Please be considerate so that everyone gets to play.
If you're curious about how Advent of Code works, it's running on some custom
Perl code. Other than a few integrations (auth, analytics, social media), I
built the whole thing myself, including the design, animations, prose, and all
of the puzzles.
The puzzles are most of the work; preparing a new calendar and a new set of
puzzles each year takes all of my free time for 4-5 months. A lot of effort
went into building this thing - I hope you're enjoying playing it as much as I
enjoyed making it for you!
If you'd like to hang out, I'm @was.tl on Bluesky, @[email protected] on
Mastodon, and @ericwastl on Twitter.
- Eric Wastl
-->
<body>
<div id="sidebar">
</div><!--/sidebar-->
<main>
<article class="day-desc"><h2>--- Day 25: Code Chronicle ---</h2><p>Out of ideas and time, The Historians agree that they should go back to check the <em>Chief Historian's office</em> one last time, just in case he went back there without you noticing.</p>
<p>When you get there, you are surprised to discover that the door to his office is <em>locked</em>! You can hear someone inside, but knocking <span title="function knock() { yield no_response; }">yields</span> no response. The locks on this floor are all fancy, expensive, virtual versions of <a href="https://en.wikipedia.org/wiki/Pin_tumbler_lock" target="_blank">five-pin tumbler locks</a>, so you contact North Pole security to see if they can help open the door.</p>
<p>Unfortunately, they've lost track of which locks are installed and which keys go with them, so the best they can do is send over <em>schematics of every lock and every key</em> for the floor you're on (your puzzle input).</p>
<p>The schematics are in a cryptic file format, but they do contain manufacturer information, so you look up their support number.</p>
<p>"Our Virtual Five-Pin Tumbler product? That's our most expensive model! <em>Way</em> more secure than--" You explain that you need to open a door and don't have a lot of time.</p>
<p>"Well, you can't know whether a key opens a lock without actually trying the key in the lock (due to quantum hidden variables), but you <em>can</em> rule out some of the key/lock combinations."</p>
<p>"The virtual system is complicated, but part of it really is a crude simulation of a five-pin tumbler lock, mostly for marketing reasons. If you look at the schematics, you can figure out whether a key could possibly fit in a lock."</p>
<p>He transmits you some example schematics:</p>
<pre><code>#####
.####
.####
.####
.#.#.
.#...
.....
#####
##.##
.#.##
...##
...#.
...#.
.....
.....
#....
#....
#...#
#.#.#
#.###
#####
.....
.....
#.#..
###..
###.#
###.#
#####
.....
.....
.....
#....
#.#..
#.#.#
#####
</code></pre>
<p>"The locks are schematics that have the top row filled (<code>#</code>) and the bottom row empty (<code>.</code>); the keys have the top row empty and the bottom row filled. If you look closely, you'll see that each schematic is actually a set of columns of various heights, either extending downward from the top (for locks) or upward from the bottom (for keys)."</p>
<p>"For locks, those are the pins themselves; you can convert the pins in schematics to a list of heights, one per column. For keys, the columns make up the shape of the key where it aligns with pins; those can also be converted to a list of heights."</p>
<p>"So, you could say the first lock has pin heights <code>0,5,3,4,3</code>:"</p>
<pre><code>#####
.####
.####
.####
.#.#.
.#...
.....
</code></pre>
<p>"Or, that the first key has heights <code>5,0,2,1,3</code>:"</p>
<pre><code>.....
#....
#....
#...#
#.#.#
#.###
#####
</code></pre>
<p>"These seem like they should fit together; in the first four columns, the pins and key don't overlap. However, this key <em>cannot</em> be for this lock: in the rightmost column, the lock's pin overlaps with the key, which you know because in that column the sum of the lock height and key height is more than the available space."</p>
<p>"So anyway, you can narrow down the keys you'd need to try by just testing each key with each lock, which means you would have to check... wait, you have <em>how</em> many locks? But the only installation <em>that</em> size is at the North--" You disconnect the call.</p>
<p>In this example, converting both locks to pin heights produces:</p>
<pre><code>0,5,3,4,3
1,2,0,5,3
</code></pre>
<p>Converting all three keys to heights produces:</p>
<pre><code>5,0,2,1,3
4,3,4,0,2
3,0,2,0,1
</code></pre>
<p>Then, you can try every key with every lock:</p>
<ul>
<li>Lock <code>0,5,3,4,3</code> and key <code>5,0,2,1,3</code>: <em>overlap</em> in the last column.</li>
<li>Lock <code>0,5,3,4,3</code> and key <code>4,3,4,0,2</code>: <em>overlap</em> in the second column.</li>
<li>Lock <code>0,5,3,4,3</code> and key <code>3,0,2,0,1</code>: all columns <em>fit</em>!</li>
<li>Lock <code>1,2,0,5,3</code> and key <code>5,0,2,1,3</code>: <em>overlap</em> in the first column.</li>
<li>Lock <code>1,2,0,5,3</code> and key <code>4,3,4,0,2</code>: all columns <em>fit</em>!</li>
<li>Lock <code>1,2,0,5,3</code> and key <code>3,0,2,0,1</code>: all columns <em>fit</em>!</li>
</ul>
<p>So, in this example, the number of unique lock/key pairs that fit together without overlapping in any column is <code><em>3</em></code>.</p>
<p>Analyze your lock and key schematics. <em>How many unique lock/key pairs fit together without overlapping in any column?</em></p>
</article>
<p>Your puzzle answer was <code>3196</code>.</p><p class="day-success">The first half of this puzzle is complete! It provides one gold star: *</p>
<article class="day-desc"><h2 id="part2">--- Part Two ---</h2><p>You and The Historians crowd into the office, startling the Chief Historian awake! The Historians all take turns looking confused until one asks where he's been for the last few months.</p>
<p>"I've been right here, working on this high-priority request from Santa! I think the only time I even stepped away was about a month ago when I went to grab a cup of coffee..."</p>
<p>Just then, the Chief notices the time. "Oh no! I'm going to be late! I must have fallen asleep trying to put the finishing touches on this <em>chronicle</em> Santa requested, but now I don't have enough time to go visit the last 50 places on my list and complete the chronicle before Santa leaves! He said he needed it before tonight's sleigh launch."</p>
<p>One of The Historians holds up the list they've been using this whole time to keep track of where they've been searching. Next to each place you all visited, they checked off that place with a <em class="star">star</em>. Other Historians hold up their own notes they took on the journey; as The Historians, how could they resist writing everything down while visiting all those historically significant places?</p>
<p>The Chief's eyes get wide. "With all this, we might just have enough time to finish the chronicle! Santa said he wanted it wrapped up with a bow, so I'll call down to the wrapping department and... hey, could <em>you</em> bring it up to Santa? I'll need to be in my seat to watch the sleigh launch by then."</p>
<p>You nod, and The Historians quickly work to collect their notes into the final set of pages for the chronicle.</p>
</article>
<p>You don't have enough stars to finish the chronicle, though. You need 14 more.</p>
<p>Although it hasn't changed, you can still <a href="25/input" target="_blank">get your puzzle input</a>.</p>
<p>You can <span class="share">[Share<span class="share-content">on
<a href="https://bsky.app/intent/compose?text=I%27ve+completed+Part+One+of+%22Code+Chronicle%22+%2D+Day+25+%2D+Advent+of+Code+2024+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F25" target="_blank">Bluesky</a>
<a href="https://twitter.com/intent/tweet?text=I%27ve+completed+Part+One+of+%22Code+Chronicle%22+%2D+Day+25+%2D+Advent+of+Code+2024&url=https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F25&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
<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+Part+One+of+%22Code+Chronicle%22+%2D+Day+25+%2D+Advent+of+Code+2024+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2024%2Fday%2F25';try{localStorage.setItem('mastodon.server',ms);}finally{}}else{return false;}" target="_blank">Mastodon</a
></span>]</span> this puzzle.</p>
</main>
<!-- ga -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-69522494-1', 'auto');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
</script>
<!-- /ga -->
</body>
</html>