-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday16.html
69 lines (66 loc) · 4.6 KB
/
day16.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
<html lang="en-us">
<head>
<meta charset="utf-8" />
<title>Advent of Code 2017</title>
<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/style.css" />
<link rel="shortcut icon" href="./assets/favicon.png" />
<script async src="./assets/header.js"></script>
</head>
<body>
<header>
<div>
<h1 class="title-global"><a href="https://adventofcode.com/2017" target="_blank">Advent of Code</a></h1>
<div class="user">John Dugan <span class="star-count"></span></div>
</div>
<div>
<h1 class="title-event"> <span class="title-event-wrap">{year=></span><a href="https://adventofcode.com/2017" target="_blank">2017</a><span class="title-event-wrap">}</span></h1>
<nav>
<ul>
<li><a href="index.html">[Calendar]</a></li>
<li><a href="https://adventofcode.com/2017/leaderboard/private/view/453227" target="_blank">[Aidn]</a></li>
<li><a href="https://adventofcode.com/2017/leaderboard/private/view/251766" target="_blank">[Memphis]</a></li>
<li><a href="https://adventofcode.com/2017/leaderboard/self" target="_blank">[Personal Stats]</a></li>
</ul>
</nav>
</div>
</header>
<main>
<article class="day-desc">
<h2>--- Day 16: Permutation Promenade ---</h2>
<p>You come upon a very unusual sight; a group of programs here appear to be <a href="https://www.youtube.com/watch?v=lyZQPjUT5B4&t=53">dancing</a>.</p>
<p>There are sixteen programs in total, named <code>a</code> through <code>p</code>. They start by standing in a <span title="This is called a 'newline'.">line</span>: <code>a</code> stands in position <code>0</code>, <code>b</code> stands in position <code>1</code>, and so on until <code>p</code>, which stands in position <code>15</code>.</p>
<p>The programs' <em>dance</em> consists of a sequence of <em>dance moves</em>:</p>
<ul>
<li><em>Spin</em>, written <code>sX</code>, makes <code>X</code> programs move from the end to the front, but maintain their order otherwise. (For example, <code>s3</code> on <code>abcde</code> produces <code>cdeab</code>).</li>
<li><em>Exchange</em>, written <code>xA/B</code>, makes the programs at positions <code>A</code> and <code>B</code> swap places.</li>
<li><em>Partner</em>, written <code>pA/B</code>, makes the programs named <code>A</code> and <code>B</code> swap places.</li>
</ul>
<p>For example, with only five programs standing in a line (<code>abcde</code>), they could do the following dance:</p>
<ul>
<li><code>s1</code>, a spin of size <code>1</code>: <code>eabcd</code>.</li>
<li><code>x3/4</code>, swapping the last two programs: <code>eabdc</code>.</li>
<li><code>pe/b</code>, swapping programs <code>e</code> and <code>b</code>: <code>baedc</code>.</li>
</ul>
<p>After finishing their dance, the programs end up in order <code>baedc</code>.<p>
<p>You watch the dance for a while and record their dance moves (your puzzle input). <em>In what order are the programs standing</em> after their dance?</p>
</article>
<p>Your puzzle answer was <code>jcobhadfnmpkglie</code>.</p>
<article class="day-desc">
<h2 id="part2">--- Part Two ---</h2><p>Now that you're starting to get a feel for the dance moves, you turn your attention to <em>the dance as a whole</em>.</p>
<p>Keeping the positions they ended up in from their previous dance, the programs perform it again and again: including the first dance, a total of <em>one billion</em> (<code>1000000000</code>) times.</p>
<p>In the example above, their second dance would <em>begin</em> with the order <code>baedc</code>, and use the same dance moves:</p>
<ul>
<li><code>s1</code>, a spin of size <code>1</code>: <code>cbaed</code>.</li>
<li><code>x3/4</code>, swapping the last two programs: <code>cbade</code>.</li>
<li><code>pe/b</code>, swapping programs <code>e</code> and <code>b</code>: <code>ceadb</code>.</li>
</ul>
<p><em>In what order are the programs standing</em> after their billion dances?</p>
</article>
<p>Your puzzle answer was <code>pclhmengojfdkaib</code>.</p>
<p class="day-success">Both parts of this puzzle are complete! They provide two gold stars: **</p>
<p>At this point, all that is left is for you to <a href="index.html">admire your Advent calendar</a>.</p>
<p>If you still want to see it, you can <a href="../data/day16/input.txt" target="_blank">get your puzzle input</a>.</p>
</main>
</body>
</html>