aoc-2018-python

Advent of Code 2018 Solutions in Python
git clone https://git.sinitax.com/sinitax/aoc-2018-python
Log | Files | Refs | README | sfeed.txt

part1 (3986B)


      1--- Day 4: Repose Record ---
      2
      3You've sneaked into another supply closet - this time, it's across from the prototype suit
      4manufacturing lab. You need to sneak inside and fix the issues with the suit, but there's a guard
      5stationed outside the lab, so this is as close as you can safely get.
      6
      7As you search the closet for anything that might help, you discover that you're not the first person
      8to want to sneak in.  Covering the walls, someone has spent an hour starting every midnight for the
      9past few months secretly observing this guard post!  They've been writing down the ID of
     10the one guard on duty that night - the Elves seem to have decided that one guard was enough for the
     11overnight shift - as well as when they fall asleep or wake up while at their post (your puzzle
     12input).
     13
     14For example, consider the following records, which have already been organized into chronological
     15order:
     16
     17[1518-11-01 00:00] Guard #10 begins shift
     18[1518-11-01 00:05] falls asleep
     19[1518-11-01 00:25] wakes up
     20[1518-11-01 00:30] falls asleep
     21[1518-11-01 00:55] wakes up
     22[1518-11-01 23:58] Guard #99 begins shift
     23[1518-11-02 00:40] falls asleep
     24[1518-11-02 00:50] wakes up
     25[1518-11-03 00:05] Guard #10 begins shift
     26[1518-11-03 00:24] falls asleep
     27[1518-11-03 00:29] wakes up
     28[1518-11-04 00:02] Guard #99 begins shift
     29[1518-11-04 00:36] falls asleep
     30[1518-11-04 00:46] wakes up
     31[1518-11-05 00:03] Guard #99 begins shift
     32[1518-11-05 00:45] falls asleep
     33[1518-11-05 00:55] wakes up
     34
     35Timestamps are written using year-month-day hour:minute format. The guard falling asleep or waking
     36up is always the one whose shift most recently started. Because all asleep/awake times are during
     37the midnight hour (00:00 - 00:59), only the minute portion (00 - 59) is relevant for those events.
     38
     39Visually, these records show that the guards are asleep at these times:
     40
     41Date   ID   Minute
     42            000000000011111111112222222222333333333344444444445555555555
     43            012345678901234567890123456789012345678901234567890123456789
     4411-01  #10  .....####################.....#########################.....
     4511-02  #99  ........................................##########..........
     4611-03  #10  ........................#####...............................
     4711-04  #99  ....................................##########..............
     4811-05  #99  .............................................##########.....
     49
     50The columns are Date, which shows the month-day portion of the relevant day; ID, which shows the
     51guard on duty that day; and Minute, which shows the minutes during which the guard was asleep within
     52the midnight hour.  (The Minute column's header shows the minute's ten's digit in the first row and
     53the one's digit in the second row.) Awake is shown as ., and asleep is shown as #.
     54
     55Note that guards count as asleep on the minute they fall asleep, and they count as awake on the
     56minute they wake up. For example, because Guard #10 wakes up at 00:25 on 1518-11-01, minute 25 is
     57marked as awake.
     58
     59If you can figure out the guard most likely to be asleep at a specific time, you might be able to
     60trick that guard into working tonight so you can have the best chance of sneaking in.  You have two
     61strategies for choosing the best guard/minute combination.
     62
     63Strategy 1: Find the guard that has the most minutes asleep. What minute does that guard spend
     64asleep the most?
     65
     66In the example above, Guard #10 spent the most minutes asleep, a total of 50 minutes (20+25+5),
     67while Guard #99 only slept for a total of 30 minutes (10+10+10). Guard #10 was asleep most during
     68minute 24 (on two days, whereas any other minute the guard was asleep was only seen on one day).
     69
     70While this example listed the entries in chronological order, your entries are in the order you
     71found them. You'll need to organize them before they can be analyzed.
     72
     73What is the ID of the guard you chose multiplied by the minute you chose? (In the above example, the
     74answer would be 10 * 24 = 240.)
     75
     76