155 lines
8.2 KiB
HTML
155 lines
8.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en-us">
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<title>Day 13 - Advent of Code 2020</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?25"/>
|
|
<link rel="stylesheet alternate" type="text/css" href="/static/highcontrast.css?0" title="High Contrast"/>
|
|
<link rel="shortcut icon" href="/favicon.png"/>
|
|
</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 @ericwastl on Twitter.
|
|
|
|
- Eric Wastl
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-->
|
|
<body>
|
|
<header><div><h1 class="title-global"><a href="/">Advent of Code</a></h1><nav><ul><li><a href="/2020/about">[About]</a></li><li><a href="/2020/events">[Events]</a></li><li><a href="https://teespring.com/stores/advent-of-code" target="_blank">[Shop]</a></li><li><a href="/2020/settings">[Settings]</a></li><li><a href="/2020/auth/logout">[Log Out]</a></li></ul></nav><div class="user">m42e <a href="/2020/support" class="supporter-badge" title="Advent of Code Supporter">(AoC++)</a> <span class="star-count">24*</span></div></div><div><h1 class="title-event"> <span class="title-event-wrap">var y=</span><a href="/2020">2020</a><span class="title-event-wrap">;</span></h1><nav><ul><li><a href="/2020">[Calendar]</a></li><li><a href="/2020/support">[AoC++]</a></li><li><a href="/2020/sponsors">[Sponsors]</a></li><li><a href="/2020/leaderboard">[Leaderboard]</a></li><li><a href="/2020/stats">[Stats]</a></li></ul></nav></div></header>
|
|
|
|
<div id="sidebar">
|
|
<div id="sponsor"><div class="quiet">Our <a href="/2020/sponsors">sponsors</a> help make Advent of Code possible:</div><div class="sponsor"><a href="https://github.com/" target="_blank" onclick="if(ga)ga('send','event','sponsor','sidebar',this.href);" rel="noopener">GitHub</a> - We're hiring engineers to make GitHub fast. Interested? Email fast@github.com with details of exceptional performance work you've done in the past.</div></div>
|
|
</div><!--/sidebar-->
|
|
|
|
<main>
|
|
<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>
|
|
<article class="day-desc"><h2>--- Day 13: Shuttle Search ---</h2><p>Your ferry can make it safely to a nearby port, but it won't get much further. When you call to book another ship, you discover that no ships embark from that port to your vacation island. You'll need to get from the port to the nearest airport.</p>
|
|
<p>Fortunately, a shuttle bus service is available to bring you from the sea port to the airport! Each bus has an ID number that also indicates <em>how often the bus leaves for the airport</em>.</p>
|
|
<p>Bus schedules are defined based on a <em>timestamp</em> that measures the <em>number of minutes</em> since some fixed reference point in the past. At timestamp <code>0</code>, every bus simultaneously departed from the sea port. After that, each bus travels to the airport, then various other locations, and finally returns to the sea port to repeat its journey forever.</p>
|
|
<p>The time this loop takes a particular bus is also its ID number: the bus with ID <code>5</code> departs from the sea port at timestamps <code>0</code>, <code>5</code>, <code>10</code>, <code>15</code>, and so on. The bus with ID <code>11</code> departs at <code>0</code>, <code>11</code>, <code>22</code>, <code>33</code>, and so on. If you are there when the bus departs, you can ride that bus to the airport!</p>
|
|
<p>Your notes (your puzzle input) consist of two lines. The first line is your estimate of the <em>earliest timestamp you could depart on a bus</em>. The second line lists the bus IDs that are in service according to the shuttle company; entries that show <code>x</code> must be out of service, so you decide to ignore them.</p>
|
|
<p>To save time once you arrive, your goal is to figure out <em>the earliest bus you can take to the airport</em>. (There will be exactly one such bus.)</p>
|
|
<p>For example, suppose you have the following notes:</p>
|
|
<pre><code>939
|
|
7,13,x,x,59,x,31,19
|
|
</code></pre>
|
|
<p>Here, the earliest timestamp you could depart is <code>939</code>, and the bus IDs in service are <code>7</code>, <code>13</code>, <code>59</code>, <code>31</code>, and <code>19</code>. Near timestamp <code>939</code>, these bus IDs depart at the times marked <code>D</code>:</p>
|
|
<pre><code>time bus 7 bus 13 bus 59 bus 31 bus 19
|
|
929 . . . . .
|
|
930 . . . D .
|
|
931 D . . . D
|
|
932 . . . . .
|
|
933 . . . . .
|
|
934 . . . . .
|
|
935 . . . . .
|
|
936 . D . . .
|
|
937 . . . . .
|
|
938 D . . . .
|
|
<em>939 . . . . .</em>
|
|
940 . . . . .
|
|
941 . . . . .
|
|
942 . . . . .
|
|
943 . . . . .
|
|
<em>944 . . D . .</em>
|
|
945 D . . . .
|
|
946 . . . . .
|
|
947 . . . . .
|
|
948 . . . . .
|
|
949 . D . . .
|
|
</code></pre>
|
|
<p>The earliest bus you could take is bus ID <code>59</code>. It doesn't depart until timestamp <code>944</code>, so you would need to wait <code>944 - 939 = 5</code> minutes before it departs. Multiplying the bus ID by the number of minutes you'd need to wait gives <em><code>295</code></em>.</p>
|
|
<p><em>What is the ID of the earliest bus you can take to the airport multiplied by the number of minutes you'll need to wait for that bus?</em></p>
|
|
</article>
|
|
<p>To begin, <a href="13/input" target="_blank">get your puzzle input</a>.</p>
|
|
<form method="post" action="13/answer"><input type="hidden" name="level" value="1"/><p>Answer: <input type="text" name="answer" autocomplete="off"/> <input type="submit" value="[Submit]"/></p></form>
|
|
<p>You can also <span class="share">[Share<span class="share-content">on
|
|
<a href="https://twitter.com/intent/tweet?text=%22Shuttle+Search%22+%2D+Day+13+%2D+Advent+of+Code+2020&url=https%3A%2F%2Fadventofcode%2Ecom%2F2020%2Fday%2F13&related=ericwastl&hashtags=AdventOfCode" target="_blank">Twitter</a>
|
|
<a href="javascript:void(0);" onclick="var mastodon_instance=prompt('Mastodon Instance / Server Name?'); if(typeof mastodon_instance==='string' && mastodon_instance.length){this.href='https://'+mastodon_instance+'/share?text=%22Shuttle+Search%22+%2D+Day+13+%2D+Advent+of+Code+2020+%23AdventOfCode+https%3A%2F%2Fadventofcode%2Ecom%2F2020%2Fday%2F13'}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> |