From: Neil Smith <neil.git@njae.me.uk> Date: Wed, 14 Dec 2016 19:57:10 +0000 (+0000) Subject: Added day 14 problem spec X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=7e9b5d3480d529e0f44bc3244018330f7edd7830;p=advent-of-code-16.git Added day 14 problem spec --- diff --git a/day14.html b/day14.html new file mode 100644 index 0000000..344600f --- /dev/null +++ b/day14.html @@ -0,0 +1,166 @@ +<!DOCTYPE html> +<html lang="en-us"> +<head> +<meta charset="utf-8"/> +<title>Day 14 - Advent of Code 2016</title> +<!--[if lt IE 9]><script src="/static/html5.js"></script><![endif]--> +<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="/static/style.css?9"/> +<link rel="shortcut icon" href="/favicon.ico?2"/> +</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 Google, 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, ads, social media), +I built the whole thing myself, including the design, animations, prose, and +all of the puzzles. + +The puzzles probably took the longest; the easiest ones were around 45 minutes +each, but the harder ones took 2-3 hours, and a few even longer than that. 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 @ericwastl on Twitter. + +- Eric Wastl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +--> +<body> +<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2016/about">[About]</a></li><li><a href="/2016/support">[AoC++]</a></li><li><a href="/2016/events">[Events]</a></li><li><a href="/2016/settings">[Settings]</a></li><li><a href="/2016/auth/logout">[Log Out]</a></li></ul></nav><div class="user">Neil Smith <span class="supporter">(AoC++)</span> <span class="star-count">28*</span></div></div><div><h1 class="title-event"> <span class="title-event-wrap">sub y{</span><a href="/2016">2016</a><span class="title-event-wrap">}</span></h1><nav><ul><li><a href="/2016">[Calendar]</a></li><li><a href="/2016/leaderboard">[Leaderboard]</a></li><li><a href="/2016/stats">[Stats]</a></li><li><a href="/2016/sponsors">[Sponsors]</a></li></ul></nav></div></header> + +<div id="sidebar"> +<div id="sponsor"><div class="quiet">Our <a href="/2016/sponsors">sponsors</a> help make AoC possible:</div><p><a href="http://www.novetta.com/careers/#opportunities" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);">Novetta</a> - Unleash your imagination. Innovate at Novetta.</p></div> +<div id="ad"> +<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> +<!-- Advent of Code Wide Skyscraper --> +<ins class="adsbygoogle" + style="display:inline-block;width:160px;height:600px" + data-ad-client="ca-pub-9420604735624631" + data-ad-slot="8014013294"></ins> +<script> +(adsbygoogle = window.adsbygoogle || []).push({}); +</script> +</div><!--/ad--> +</div><!--/sidebar--> + +<main> +<article class="day-desc"><h2>--- Day 14: One-Time Pad ---</h2><p>In order to communicate securely with Santa while you're on this mission, you've been using a <a href="https://en.wikipedia.org/wiki/One-time_pad">one-time pad</a> that you <a href="https://en.wikipedia.org/wiki/Security_through_obscurity">generate</a> using a <span title="This also happens to be the plot of World War II.">pre-agreed algorithm</span>. Unfortunately, you've run out of keys in your one-time pad, and so you need to generate some more.</p> +<p>To generate keys, you first get a stream of random data by taking the <a href="https://en.wikipedia.org/wiki/MD5">MD5</a> of a pre-arranged <a href="https://en.wikipedia.org/wiki/Salt_(cryptography)">salt</a> (your puzzle input) and an increasing integer index (starting with <code>0</code>, and represented in decimal); the resulting MD5 hash should be represented as a string of <em>lowercase</em> hexadecimal digits.</p> +<p>However, not all of these MD5 hashes are <em>keys</em>, and you need <code>64</code> new keys for your one-time pad. A hash is a key <em>only if</em>:</p> +<ul> +<li>It contains <em>three</em> of the same character in a row, like <code>777</code>. Only consider the first such triplet in a hash.</li> +<li>One of the next <code>1000</code> hashes in the stream contains that same character <em>five</em> times in a row, like <code>77777</code>.</li> +</ul> +<p>Considering future hashes for five-of-a-kind sequences does not cause those hashes to be skipped; instead, regardless of whether the current hash is a key, always resume testing for keys starting with the very next hash.</p> +<p>For example, if the pre-arranged salt is <code>abc</code>:</p> +<ul> +<li>The first index which produces a triple is <code>18</code>, because the MD5 hash of <code>abc18</code> contains <code>...cc38887a5...</code>. However, index <code>18</code> does not count as a key for your one-time pad, because none of the next thousand hashes (index <code>19</code> through index <code>1018</code>) contain <code>88888</code>.</li> +<li>The next index which produces a triple is <code>39</code>; the hash of <code>abc39</code> contains <code>eee</code>. It is also the first key: one of the next thousand hashes (the one at index 816) contains <code>eeeee</code>.</li> +<li>None of the next six triples are keys, but the one after that, at index <code>92</code>, is: it contains <code>999</code> and index <code>200</code> contains <code>99999</code>.</li> +<li>Eventually, index <code>22728</code> meets all of the criteria to generate the <code>64</code>th key.</li> +</ul> +<p>So, using our example salt of <code>abc</code>, index <code>22728</code> produces the <code>64</code>th key.</p> +<p>Given the actual salt in your puzzle input, <em>what index</em> produces your <code>64</code>th one-time pad key?</p> +</article> +<p>Your puzzle answer was <code>25427</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Of course, in order to make this process <a href="https://en.wikipedia.org/wiki/MD5#Security">even more secure</a>, you've also implemented <a href="https://en.wikipedia.org/wiki/Key_stretching">key stretching</a>.</p> +<p>Key stretching forces attackers to spend more time generating hashes. Unfortunately, it forces everyone else to spend more time, too.</p> +<p>To implement key stretching, whenever you generate a hash, before you use it, you first find the MD5 hash of that hash, then the MD5 hash of <em>that</em> hash, and so on, a total of <em><code>2016</code> additional hashings</em>. Always use lowercase hexadecimal representations of hashes.</p> +<p>For example, to find the stretched hash for index <code>0</code> and salt <code>abc</code>:</p> +<ul> +<li>Find the MD5 hash of <code>abc0</code>: <code>577571be4de9dcce85a041ba0410f29f</code>.</li> +<li>Then, find the MD5 hash of that hash: <code>eec80a0c92dc8a0777c619d9bb51e910</code>.</li> +<li>Then, find the MD5 hash of that hash: <code>16062ce768787384c81fe17a7a60c7e3</code>.</li> +<li>...repeat many times...</li> +<li>Then, find the MD5 hash of that hash: <code>a107ff634856bb300138cac6568c0f24</code>.</li> +</ul> +<p>So, the stretched hash for index <code>0</code> in this situation is <code>a107ff...</code>. In the end, you find the original hash (one use of MD5), then find the hash-of-the-previous-hash <code>2016</code> times, for a total of <code>2017</code> uses of MD5.</p> +<p>The rest of the process remains the same, but now the keys are entirely different. Again for salt <code>abc</code>:</p> +<ul> +<li>The first triple (<code>222</code>, at index <code>5</code>) has no matching <code>22222</code> in the next thousand hashes.</li> +<li>The second triple (<code>eee</code>, at index <code>10</code>) hash a matching <code>eeeee</code> at index <code>89</code>, and so it is the first key.</li> +<li>Eventually, index <code>22551</code> produces the <code>64</code>th key (triple <code>fff</code> with matching <code>fffff</code> at index <code>22859</code>.</li> +</ul> +<p>Given the actual salt in your puzzle input and using <code>2016</code> extra MD5 calls of key stretching, <em>what index</em> now produces your <code>64</code>th one-time pad key?</p> +</article> +<p>Your puzzle answer was <code>22045</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="/2016">return to your advent calendar</a> and try another puzzle.</p> +<p>Your puzzle input was <code class="puzzle-input">yjdafjpo</code>.</p> +<p>You can also <span class="share">[Share<span class="share-content">on + <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22One%2DTime+Pad%22+%2D+Day+14+%2D+Advent+of+Code+2016&url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F14&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a> + <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F14" target="_blank">Google+</a> + <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F14&title=I%27ve+completed+%22One%2DTime+Pad%22+%2D+Day+14+%2D+Advent+of+Code+2016" target="_blank">Reddit</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('send', 'pageview'); +</script> +<!-- /ga --> +</body> +</html> \ No newline at end of file