Advent of Code 2021: Day 8
β’ 75 words β’ 1 min β’ updated
β οΈ This post is over one year old. It may no longer be up to date or relevant. Opinions may have changed.
Refer to the previous post about AoC, and to the git repository with my solutions in Python 3.
Link to Day #8 puzzle.
Decode seven-segment display signals. Count unique digit segments in output values.
python
#!/usr/bin/env python3
import sys
with open(sys.argv[1]) as input:
lines = input.read().splitlines()
def part1():
total = 0
for line in lines:
outputs = line.split(' | ')[1].split(' ')
total += sum(len(output) in [2, 3, 4, 7] for output in outputs)
print(total)
part1()