d5 part1 done
This commit is contained in:
parent
17687ac959
commit
ea783ba9c0
62
day5.py
Normal file
62
day5.py
Normal file
|
@ -0,0 +1,62 @@
|
|||
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)
|
1000
inputs/day5.txt
Normal file
1000
inputs/day5.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user