Removed needless directory
[advent-of-code-16.git] / day09.html
1 <!DOCTYPE html>
2 <html lang="en-us">
3 <head>
4 <meta charset="utf-8"/>
5 <title>Day 9 - Advent of Code 2016</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?8"/>
9 <link rel="shortcut icon" href="/favicon.ico?2"/>
10 </head><!--
11
12
13
14
15 Oh, hello! Funny seeing you here.
16
17 I appreciate your enthusiasm, but you aren't going to find much down here.
18 There certainly aren't clues to any of the puzzles. The best surprises don't
19 even appear in the source until you unlock them for real.
20
21 Please be careful with automated requests; I'm not Google, and I can only take
22 so much traffic. Please be considerate so that everyone gets to play.
23
24 If you're curious about how Advent of Code works, it's running on some custom
25 Perl code. Other than a few integrations (auth, analytics, ads, social media),
26 I built the whole thing myself, including the design, animations, prose, and
27 all of the puzzles.
28
29 The puzzles probably took the longest; the easiest ones were around 45 minutes
30 each, but the harder ones took 2-3 hours, and a few even longer than that. A
31 lot of effort went into building this thing - I hope you're enjoying playing it
32 as much as I enjoyed making it for you!
33
34 If you'd like to hang out, I'm @ericwastl on Twitter.
35
36 - Eric Wastl
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 <body>
89 <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">18*</span></div></div><div><h1 class="title-event">&nbsp;&nbsp;&nbsp;<span class="title-event-wrap">var 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>
90
91 <div id="sidebar">
92 <div id="sponsor"><div class="quiet">Our <a href="/2016/sponsors">sponsors</a> help make AoC possible:</div><p><a href="https://www.detroitlabs.com/careers" target="_blank" onclick="if(ga)ga('send','event','sponsor','click',this.href);">Detroit Labs</a> - Build beautiful mobile apps.</p></div>
93 <div id="ad">
94 <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
95 <!-- Advent of Code Wide Skyscraper -->
96 <ins class="adsbygoogle"
97 style="display:inline-block;width:160px;height:600px"
98 data-ad-client="ca-pub-9420604735624631"
99 data-ad-slot="8014013294"></ins>
100 <script>
101 (adsbygoogle = window.adsbygoogle || []).push({});
102 </script>
103 </div><!--/ad-->
104 </div><!--/sidebar-->
105
106 <main>
107 <article class="day-desc"><h2>--- Day 9: Explosives in Cyberspace ---</h2><p>Wandering around a secure area, you come across a datalink port to a new part of the network. After briefly scanning it for interesting files, you find one file in particular that catches your attention. It's compressed with an experimental format, but fortunately, the documentation for the format is nearby.</p>
108 <p>The format compresses a sequence of characters. Whitespace is ignored. To indicate that some sequence should be repeated, a marker is added to the file, like <code>(10x2)</code>. To decompress this marker, take the subsequent <code>10</code> characters and repeat them <code>2</code> times. Then, continue reading the file <em>after</em> the repeated data. The marker itself is not included in the decompressed output.</p>
109 <p>If parentheses or other characters appear within the data referenced by a marker, that's okay - treat it like normal data, not a marker, and then resume looking for markers after the decompressed section.</p>
110 <p>For example:</p>
111 <ul>
112 <li><code>ADVENT</code> contains no markers and decompresses to itself with no changes, resulting in a decompressed length of <code>6</code>.</li>
113 <li><code>A(1x5)BC</code> repeats only the <code>B</code> a total of <code>5</code> times, becoming <code>ABBBBBC</code> for a decompressed length of <code>7</code>.</li>
114 <li><code>(3x3)XYZ</code> becomes <code>XYZXYZXYZ</code> for a decompressed length of <code>9</code>.</li>
115 <li><code>A(2x2)BCD(2x2)EFG</code> doubles the <code>BC</code> and <code>EF</code>, becoming <code>ABCBCDEFEFG</code> for a decompressed length of <code>11</code>.</li>
116 <li><code>(6x1)(1x3)A</code> simply becomes <code>(1x3)A</code> - the <code>(1x3)</code> looks like a marker, but because it's within a data section of another marker, it is not treated any differently from the <code>A</code> that comes after it. It has a decompressed length of <code>6</code>.</li>
117 <li><code>X(8x2)(3x3)ABCY</code> becomes <code>X(3x3)ABC(3x3)ABCY</code> (for a decompressed length of <code>18</code>), because the decompressed data from the <code>(8x2)</code> marker (the <code>(3x3)ABC</code>) is skipped and not processed further.</li>
118 </ul>
119 <p>What is the <em>decompressed length</em> of the file (your puzzle input)? Don't count whitespace.</p>
120 </article>
121 <p>Your puzzle answer was <code>123908</code>.</p><article class="day-desc"><h2>--- Part Two ---</h2><p>Apparently, the file actually uses <em>version two</em> of the format.</p>
122 <p>In version two, the only difference is that markers within decompressed data <em>are</em> decompressed. This, the documentation explains, provides much more substantial compression capabilities, allowing many-gigabyte files to be stored in <span title="&quot;It's the bomb!&quot;, the documentation claims.">only a few kilobytes</span>.</p>
123 <p>For example:</p>
124 <ul>
125 <li><code>(3x3)XYZ</code> still becomes <code>XYZXYZXYZ</code>, as the decompressed section contains no markers.</li>
126 <li><code>X(8x2)(3x3)ABCY</code> becomes <code>XABCABCABCABCABCABCY</code>, because the decompressed data from the <code>(8x2)</code> marker is then further decompressed, thus triggering the <code>(3x3)</code> marker twice for a total of six <code>ABC</code> sequences.</li>
127 <li><code>(27x12)(20x12)(13x14)(7x10)(1x12)A</code> decompresses into a string of <code>A</code> repeated <code>241920</code> times.</li>
128 <li><code>(25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN</code> becomes <code>445</code> characters long.</li>
129 </ul>
130 <p>Unfortunately, the computer you brought probably doesn't have enough memory to actually decompress the file; you'll have to <em>come up with another way</em> to get its decompressed length.</p>
131 <p>What is the <em>decompressed length</em> of the file using this improved format?</p>
132 </article>
133 <p>Your puzzle answer was <code>10755693147</code>.</p><p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
134 <p>At this point, you should <a href="/2016">return to your advent calendar</a> and try another puzzle.</p>
135 <p>If you still want to see it, you can <a href="9/input" target="_blank">get your puzzle input</a>.</p>
136 <p>You can also <span class="share">[Share<span class="share-content">on
137 <a href="https://twitter.com/intent/tweet?text=I%27ve+completed+%22Explosives+in+Cyberspace%22+%2D+Day+9+%2D+Advent+of+Code+2016&amp;url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F9&amp;related=ericwastl&amp;hashtags=AdventOfCode" target="_blank">Twitter</a>
138 <a href="https://plus.google.com/share?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F9" target="_blank">Google+</a>
139 <a href="http://www.reddit.com/submit?url=http%3A%2F%2Fadventofcode%2Ecom%2F2016%2Fday%2F9&amp;title=I%27ve+completed+%22Explosives+in+Cyberspace%22+%2D+Day+9+%2D+Advent+of+Code+2016" target="_blank">Reddit</a
140 ></span>]</span> this puzzle.</p>
141 </main>
142
143 <!-- ga -->
144 <script>
145 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
146 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
147 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
148 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
149 ga('create', 'UA-69522494-1', 'auto');
150 ga('send', 'pageview');
151 </script>
152 <!-- /ga -->
153 </body>
154 </html>