Skip to content

Instantly share code, notes, and snippets.

@loudambiance
Created December 17, 2021 04:10
Show Gist options
  • Save loudambiance/5352d07b12bf36bf30d8bd3e8144d23d to your computer and use it in GitHub Desktop.
Save loudambiance/5352d07b12bf36bf30d8bd3e8144d23d to your computer and use it in GitHub Desktop.
test = False
file = 'data/task8test.txt' if test else 'data/task8.txt'
data = []
with open(file) as f:
lines = f.read().splitlines()
for line in lines:
data.extend(line.split(' | ')[1].split(' '))
count = sum(list(map(lambda x: 1 if len(x) == 2 or len(x) == 3 or len(x) == 4 or len (x)==7 else 0, data)))
print(count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment