Skip to content

Instantly share code, notes, and snippets.

@Mu-adventofcode
Created April 30, 2022 20:12
Show Gist options
  • Save Mu-adventofcode/c07a7d4f55e3d2510eafa8b025c403f7 to your computer and use it in GitHub Desktop.
Save Mu-adventofcode/c07a7d4f55e3d2510eafa8b025c403f7 to your computer and use it in GitHub Desktop.
Advent of Code 2021 day 08 part 1
from collections import Counter
with open("input.txt") as txt:
output_values = [line.split(" | ")[1].strip() for line in txt]
digit_lengths = [len(d) for val in output_values for d in val.split()]
counts = Counter(digit_lengths)
total = sum(counts[i] for i in (2, 4, 3, 7)) # lens of digits 1, 4, 7 resp 8
print(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment