AdventOfCode2015/day5.py

62 lines
1.2 KiB
Python
Raw Permalink Normal View History

2022-12-16 22:28:45 +01:00
day ="5"
file= f"inputs/day{day}.txt"
def part_one(file):
input = open(file, 'r')
input = input.readlines()
result = 0
for line in input:
if check_aeiou(line) and check_double(line) and not check_ab_cd_pq_xy(line):
print(line)
result +=1
print(f"Part 1: {result}")
def check_aeiou(line):
check = False
counter = 0
for c in line:
for char in "aeiou":
if char ==c:
counter +=1
if counter > 2:
check = True
print(f"aeiou check: {check}")
return check
def check_double(line):
check = False
counter = 1
double = 0
prev_char = line[0]
while counter < len(line):
if line[counter] == prev_char:
double +=1
if double == 1:
check = True
break
prev_char = line[counter]
counter += 1
print(f"double check: {check}")
return check
def check_ab_cd_pq_xy(line):
check = False
if ("ab" in line) or ("cd" in line) or ("pq" in line) or ("xy" in line):
check = True
print(f"ab_cd check: {check}")
return check
def part_two(file):
input = open(file, 'r')
result = 0
print(f"Part 2: {result}")
part_one(file)
part_two(file)