VP 59: Box IDs (30 extra)
What You Need
Any computer with Python 3. You can also use
an online Python environment, such as
https://colab.research.google.com
Problem Statement
Your input is a list of box IDs, each of which is a string of letters.
Your task is to find two numbers:
- Count the number of Box IDs that contain exactly two of a letter
- Count the number of Box IDs that contain exactly three of a letter
Multiply those two numbers together to create a checksum.
For example, if you see the following box IDs:
- abcdef contains no letters that appear exactly two or three times.
- bababc contains two a and three b, so it counts for both.
- abbcde contains two b, but no letter appears exactly three times.
- abcccd contains three c, but no letter appears exactly two times.
- aabcdd contains two a and two d, but it only counts once.
- abcdee contains two e.
- ababab contains three a and three b, but it only counts once.
Of these box IDs, four of them contain a letter which appears exactly twice, and three of them contain a letter which appears exactly three times. Multiplying these together produces a checksum of 4 * 3 = 12.
What is the checksum for your list of box IDs?
Part 2: Similar IDs
Find two boxes will have IDs which differ by exactly one character at the same position in both strings.
For example, given the following box IDs::
abcde
fghij
klmno
pqrst
fguij
axcye
wvxyz
The IDs abcde and axcye are close, but they differ by two characters (the second and fourth).
However, the IDs fghij and fguij differ by exactly one character, the third (h and u). Those are the correct boxes.
What letters do these boxes have in common? fgij
Source
Adapted from the Advent of Code.
Posted 11-3-25