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 (2385B)


      1--- Day 2: Inventory Management System ---
      2
      3You stop falling through time, catch your breath, and check the screen on the device. "Destination
      4reached. Current Year: 1518. Current Location: North Pole Utility Closet 83N10." You made it! Now,
      5to find those anomalies.
      6
      7Outside the utility closet, you hear footsteps and a voice. "...I'm not sure either. But now that so
      8many people have chimneys, maybe he could sneak in that way?" Another voice responds, "Actually,
      9we've been working on a new kind of suit that would let him fit through tight spaces like that. But,
     10I heard that a few days ago, they lost the prototype fabric, the design plans, everything! Nobody on
     11the team can even seem to remember important details of the project!"
     12
     13"Wouldn't they have had enough fabric to fill several boxes in the warehouse? They'd be stored
     14together, so the box IDs should be similar. Too bad it would take forever to search the warehouse
     15for two similar box IDs..." They walk too far away to hear any more.
     16
     17Late at night, you sneak to the warehouse - who knows what kinds of paradoxes you could cause if you
     18were discovered - and use your fancy wrist device to quickly scan every box and produce a list of
     19the likely candidates (your puzzle input).
     20
     21To make sure you didn't miss any, you scan the likely candidate boxes again, counting the number
     22that have an ID containing exactly two of any letter and then separately counting those with
     23exactly three of any letter. You can multiply those two counts together to get a rudimentary
     24checksum and compare it to what your device predicts.
     25
     26For example, if you see the following box IDs:
     27
     28
     29 - abcdef contains no letters that appear exactly two or three times.
     30
     31 - bababc contains two a and three b, so it counts for both.
     32
     33 - abbcde contains two b, but no letter appears exactly three times.
     34
     35 - abcccd contains three c, but no letter appears exactly two times.
     36
     37 - aabcdd contains two a and two d, but it only counts once.
     38
     39 - abcdee contains two e.
     40
     41 - ababab contains three a and three b, but it only counts once.
     42
     43
     44Of these box IDs, four of them contain a letter which appears exactly twice, and three of them
     45contain a letter which appears exactly three times. Multiplying these together produces a checksum
     46of 4 * 3 = 12.
     47
     48What is the checksum for your list of box IDs?
     49
     50