mirror of
https://github.com/jneug/adventofcode.git
synced 2026-04-14 06:43:33 +02:00
15 lines
450 B
Python
15 lines
450 B
Python
input = []
|
|
with open('day2_input.txt', 'r') as f:
|
|
for line in f.readlines():
|
|
line = line.split(' ');
|
|
a,b = line[0].split('-');
|
|
input.append(((int(a),int(b)), line[1][0], line[2].strip()))
|
|
|
|
def check_pwd(p):
|
|
rule, char, pwd = p[0], p[1], p[2]
|
|
if (pwd[rule[0]-1] == char or pwd[rule[1]-1] == char) and (pwd[rule[0]-1] != pwd[rule[1]-1]):
|
|
return 1
|
|
else:
|
|
return 0
|
|
|
|
print(sum(map(check_pwd, input))) |