Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline; filename="2d4e8cc331246c18f7ce12b942a6bfdf36fc3d4d..3310dfa6a901f188a97f3023ffb9c212ee14e439.patch"
Last-Modified: Tue, 03 Nov 2026 06:28:40 GMT
Expires: Fri, 31 Oct 2036 06:28:40 GMT

From 3310dfa6a901f188a97f3023ffb9c212ee14e439 Mon Sep 17 00:00:00 2001
From: June McEnroe <june@causal.agency>
Date: Sat, 17 Dec 2016 00:18:36 -0500
Subject: Day 14

---
 src/bin/day14.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 src/bin/day14.rs

(limited to 'src/bin/day14.rs')

diff --git a/src/bin/day14.rs b/src/bin/day14.rs
new file mode 100644
index 0000000..b22e88d
--- /dev/null
+++ b/src/bin/day14.rs
@@ -0,0 +1,60 @@
+extern crate crypto;
+
+use std::collections::VecDeque;
+use std::io::{self, Read};
+use std::iter;
+
+use crypto::digest::Digest;
+use crypto::md5::Md5;
+
+fn md5(salt: &str, index: u32) -> String {
+    let mut md5 = Md5::new();
+    md5.input_str(salt);
+    md5.input_str(&index.to_string());
+    md5.result_str()
+}
+
+fn solve(salt: &str) -> u32 {
+    let mut hashes = VecDeque::new();
+    for i in 0..1001 {
+        hashes.push_back(md5(salt, i));
+    }
+
+    let mut keys = 0;
+    let mut index = 0;
+    while let Some(hash) = hashes.pop_front() {
+        let triple = hash.as_bytes()
+            .windows(3)
+            .filter(|w| w[0] == w[1] && w[1] == w[2])
+            .map(|w| w[0])
+            .next();
+
+        if let Some(ch) = triple {
+            let quintuple: String = iter::repeat(ch as char).take(5).collect();
+            if hashes.iter().any(|hash| hash.contains(&quintuple)) {
+                keys += 1;
+                if keys == 64 {
+                    return index;
+                }
+            }
+        }
+
+        index += 1;
+        hashes.push_back(md5(salt, 1000 + index));
+    }
+
+    unreachable!()
+}
+
+fn main() {
+    let mut input = String::new();
+    io::stdin().read_to_string(&mut input).unwrap();
+
+    println!("Part 1: {}", solve(input.trim()));
+}
+
+#[test]
+#[ignore]
+fn part1() {
+    assert_eq!(22728, solve("abc"));
+}
-- 
cgit 1.4.1

option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit-pink/log/?h=1.3.0&amp;id=be6a526a74199d1ff1cf69e5dff3171a63ffc7f7'>root</a>/<a href='/cgit-pink/log/git?h=1.3.0&amp;id=be6a526a74199d1ff1cf69e5dff3171a63ffc7f7'>git</a> (<a href='/cgit-pink/log/git?h=1.3.0&amp;id=be6a526a74199d1ff1cf69e5dff3171a63ffc7f7&amp;follow=1'>follow</a>)</div><div class='content'><table class='list nowrap'><tr class='nohover'><th></th><th class='left'>Commit message (<a href='/cgit-pink/log/git?h=1.3.0&amp;id=be6a526a74199d1ff1cf69e5dff3171a63ffc7f7&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Age</th></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=fde897b8171ed2e925b44ec6f69590ec07241017'>git: update to v2.25.1</a></td><td>Christian Hesse</td><td><span title='2020-02-17 13:08:02 +0100'>2020-02-17</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=bd68c98879ecc8ce9f7f6d3e01bc4ffeb9182b04'>git: update to v2.25.0</a></td><td>Christian Hesse</td><td><span title='2020-01-13 14:50:55 -0500'>2020-01-13</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=d8e5dd25a0d2e32ef3453a96112eea817336e4d7'>git: update to v2.24.1</a></td><td>Christian Hesse</td><td><span title='2019-12-10 20:57:24 +0100'>2019-12-10</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=bfabd4519c80f39eedba3dd5d522563899e364c9'>git: update to v2.24.0</a></td><td>Christian Hesse</td><td><span title='2019-11-08 22:55:58 +0100'>2019-11-08</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=8fc0c81bbbed21ee30e8a48b2ab1066a029b7b32'>git: update to v2.23.0</a></td><td>Christian Hesse</td><td><span title='2019-10-25 11:40:17 +0200'>2019-10-25</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=034e3c7d56ba71ce281886fe8525b16d4559fac1'>git: update to v2.22.0</a></td><td>Christian Hesse</td><td><span title='2019-10-25 11:40:17 +0200'>2019-10-25</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=985fba80d06f37fdba5e72d738ce21ab5ab5a76d'>git: update to v2.21.0</a></td><td>Christian Hesse</td><td><span title='2019-06-05 15:37:49 +0200'>2019-06-05</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=55ebd5e97ccd0da9424d68f1e0f301551cf4b47a'>git: update to v2.20.0</a></td><td>Christian Hesse</td><td><span title='2018-12-09 23:28:26 +0100'>2018-12-09</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=2c9f56f3e1c754f60ccffbc6c745b9d5a81ea005'>git: update to v2.19.1</a></td><td>Christian Hesse</td><td><span title='2018-10-12 23:06:02 +0200'>2018-10-12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=255b78ff5291cef79978b025c9872f801de89e23'>git: update to v2.18.0</a></td><td>Christian Hesse</td><td><span title='2018-06-27 18:13:03 +0200'>2018-06-27</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=fb804a353780633b23a5452b3893fcc9f3705431'>git: update to v2.17.1</a></td><td>Christian Hesse</td><td><span title='2018-06-27 18:01:29 +0200'>2018-06-27</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=1dd53e3a2ffec730ec27ebe15b3d63e0b417a544'>git: update to v2.16.0</a></td><td>Christian Hesse</td><td><span title='2018-01-19 11:34:43 +0100'>2018-01-19</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=5d947ba3f06ec2c7200aab8c22170e7f2bf55a7c'>git: update to v2.15.1</a></td><td>Christian Hesse</td><td><span title='2017-12-06 20:29:10 +0100'>2017-12-06</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=86a6d358f7a6c2432fde86b9e3c5011a656f20e4'>git: update to v2.14</a></td><td>Jeff Smith</td><td><span title='2017-08-10 15:58:24 +0200'>2017-08-10</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=3d33b46df24d4dee140d0aafb1eba5fffa314cf0'>git: update to v2.13.4</a></td><td>Christian Hesse</td><td><span title='2017-08-10 15:15:54 +0200'>2017-08-10</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=91153fd02e62f2eaca8e6c140baa4f2abf39c40e'>git: update to v2.11.0</a></td><td>Christian Hesse</td><td><span title='2016-11-30 10:43:08 +0100'>2016-11-30</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=5ccd96525835b314c8615738d533d9d0b54a630c'>git: update to v2.10.2 again</a></td><td>John Keeping</td><td><span title='2016-11-24 18:59:42 +0000'>2016-11-24</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=8e9ddd21a50beb9fd660cf6cd6a583234924b932'>Bump version.</a></td><td>Jason A. Donenfeld</td><td><span title='2016-11-23 05:24:36 +0100'>2016-11-23</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=44f8c11c8d6edadedb9b83baf6f6a786c0bd8c30'>git: update to v2.10.2</a></td><td>Christian Hesse</td><td><span title='2016-11-06 21:47:04 +0100'>2016-11-06</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=d6a4730d049216f903fb0466215366f588208a40'>git: update to v2.10.1</a></td><td>Christian Hesse</td><td><span title='2016-10-04 21:54:30 +0200'>2016-10-04</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=11695a58fd732689be486edf88d145578a787c89'>git: update to v2.10.0</a></td><td>Christian Hesse</td><td><span title='2016-09-04 12:38:18 +0200'>2016-09-04</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=d6b0332982234c73a26119e4ed60d442870b8078'>git: update to v2.9.1</a></td><td>Christian Hesse</td><td><span title='2016-07-12 01:04:56 +0200'>2016-07-12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=1e039ada8554c7e2fc65524827c61613a24256fb'>git: update to v2.9.0</a></td><td>Christian Hesse</td><td><span title='2016-06-17 12:36:58 +0200'>2016-06-17</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=41508c091186ece4cdc5d79c5ac0d2eda3d3edef'>git: update to v2.8.3</a></td><td>Christian Hesse</td><td><span title='2016-05-20 11:04:43 +0900'>2016-05-20</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=86bf5b47916fbe53fe637d7181e93a34d2ad6d0c'>git: update to v2.8.2</a></td><td>Christian Hesse</td><td><span title='2016-05-12 17:23:29 +0200'>2016-05-12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=a9e9dfc55f5c57a4065be77c320224f524a9c820'>git: update to v2.7.2</a></td><td>Christian Hesse</td><td><span title='2016-02-23 03:16:26 +0100'>2016-02-23</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=85ec9f0211a0c83d6cca744e6e40d73daf4050fc'>git: update to v2.7.1</a></td><td>Christian Hesse</td><td><span title='2016-02-08 14:24:52 +0100'>2016-02-08</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=559ab5ecc4445c8477ecf62c9fc97efa412dd562'>git: update to v2.7.0</a></td><td>Christian Hesse</td><td><span title='2016-01-13 17:12:17 +0100'>2016-01-13</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=978ce8c00c0d3117f6470a77b08aa0f97984604f'>git: update to v2.6.1</a></td><td>Christian Hesse</td><td><span title='2015-10-06 16:39:06 +0200'>2015-10-06</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=de83de276bef7509ab8255682595ad4521f3a193'>git: update to v2.5.0</a></td><td>Christian Hesse</td><td><span title='2015-08-12 14:09:05 +0200'>2015-08-12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=2eb41c4665ad6866c8893668263c401d7b0ffc5d'>git: update to v2.4.1</a></td><td>Christian Hesse</td><td><span title='2015-05-14 13:49:12 +0200'>2015-05-14</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=84627609f5a7634732fe1d718e7d1c18254e64c8'>git: update to v2.3.3</a></td><td>Christian Hesse</td><td><span title='2015-03-14 17:56:15 +0100'>2015-03-14</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=97a91657a5032aa984d91344b91e1c5a084c2f0d'>git: update to v2.3.2</a></td><td>Christian Hesse</td><td><span title='2015-03-07 12:45:58 +0100'>2015-03-07</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=911d574250d3a2ae97f282fb8f466db2afa1cd64'>git: update to v2.3.1</a></td><td>Christian Hesse</td><td><span title='2015-03-03 16:47:22 +0100'>2015-03-03</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=7358f63015a27d1c22816a3c1f734c3d4beed115'>git: update for v2.3.0</a></td><td>Christian Hesse</td><td><span title='2015-02-08 18:11:09 +0100'>2015-02-08</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=c641e0ab64f447cd39c6d5737fd498ace3ed8735'>git: update to v2.2.2</a></td><td>Christian Hesse</td><td><span title='2015-01-13 14:54:22 +0100'>2015-01-13</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=17838ec6304198811df97402f11c185f8f0e10bd'>git: update to v2.2.1</a></td><td>Christian Hesse</td><td><span title='2014-12-23 18:53:03 -0700'>2014-12-23</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=49f607777fe3d9393574a572d72caa568ee3ca3c'>git: update to v2.0.4</a></td><td>John Keeping</td><td><span title='2014-08-07 14:42:34 +0200'>2014-08-07</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=865afe0eb1b5e6485fe0f65472e6635266e393b1'>git: update to v2.0.3</a></td><td>John Keeping</td><td><span title='2014-07-28 02:01:35 +0200'>2014-07-28</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=390ffad022336b02dca6dec23504cefeb12adada'>git: update to 2.0.1</a></td><td>Christian Hesse</td><td><span title='2014-06-28 16:07:30 +0200'>2014-06-28</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=79c985e13c10b498c3ea62f4607c2e2a460c3b10'>git: update for git 2.0</a></td><td>Christian Hesse</td><td><span title='2014-06-28 15:14:56 +0200'>2014-06-28</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=dcb16f0d11305b4d7cb6357c5c0e21ad67f69871'>git: update to 1.9.2</a></td><td>Christian Hesse</td><td><span title='2014-04-12 18:05:43 +0200'>2014-04-12</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=45315f846c2e2ee6663f0ba8cc454384d2b9e3ea'>git: update to 1.9.1</a></td><td>Christian Hesse</td><td><span title='2014-03-20 11:14:03 -0600'>2014-03-20</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=8033dc01f4ae1551c21769f580caa723fb176d9c'>git: Update to 1.9.0</a></td><td>Lukas Fleischer</td><td><span title='2014-02-21 01:18:54 +0100'>2014-02-21</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=3cebf6838b0739caaf711255d4c3a397d1e3046a'>git: update to 1.8.5</a></td><td>Christian Hesse</td><td><span title='2014-01-08 14:59:38 +0100'>2014-01-08</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=d62e71a0240a7506b870b99e5c068f336e0a137e'>git: update to 1.8.4</a></td><td>John Keeping</td><td><span title='2013-08-26 18:42:03 +0200'>2013-08-26</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=0499e88ccec43dc69233841779ab4b71b5d94dac'>git: update to 1.8.3</a></td><td>John Keeping</td><td><span title='2013-05-25 13:10:14 +0200'>2013-05-25</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=83115075abe970306a79484dbaa9adfa97fef2d0'>git: update to 1.8.2.2</a></td><td>John Keeping</td><td><span title='2013-04-27 17:13:46 +0200'>2013-04-27</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=849ecd961df9454d6f849eac34e6f501395c4f01'>Update git to v1.8.2.1</a></td><td>John Keeping</td><td><span title='2013-04-08 15:41:38 +0200'>2013-04-08</span></td></tr>
<tr><td class='commitgraph'>* </td><td><a href='/cgit-pink/commit/git?h=1.3.0&amp;id=7f4e8c33aeb65bdc5695c9fd13ec1ceb100303c7'>Update git to v1.7.12.4</a></td><td>John Keeping</td><td><span title='2013-03-02 10:38:03 -0500'>2013-03-02</span></td></tr>
</table><ul class='pager'><li><a href='/cgit-pink/log/git?h=1.3.0&amp;id=be6a526a74199d1ff1cf69e5dff3171a63ffc7f7&amp;ofs=50'>[next]</a></li></ul></div> <!-- class=content -->
<div class='footer'>generated by <a href='https://git.causal.agency/cgit-pink/about/'>cgit-pink 1.4.1</a> (<a href='https://git-scm.com/'>git 2.36.1</a>) at 2026-11-03 06:28:40 +0000</div>
</div> <!-- id=cgit -->
</body>
</html>
