From b3809fabc76370b8d1c46b9224f23693a55e022b Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Sat, 9 Dec 2023 21:38:20 +0100 Subject: [PATCH] Starting on 2015-12-05 p2 --- 2015/day5/part2.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 2015/day5/part2.py diff --git a/2015/day5/part2.py b/2015/day5/part2.py new file mode 100644 index 0000000..869570b --- /dev/null +++ b/2015/day5/part2.py @@ -0,0 +1,40 @@ +#!/bin/python3 + +import sys +from pprint import pprint + +input_f = sys.argv[1] + +result = 0 + +with open(input_f) as file: + for line in file: + tmp = line.rstrip() + print(tmp) + vowel_count = 0 + t = ['ab','cd','pq','xy'] + first = False + second = False + for i in t: + if tmp.find(i) != -1: + print(" is naughty because it contains " + i) + first = True + break + f = 'aeiou' + for idx,i in enumerate(tmp): + if idx+1 < len(tmp) and first == False: + #print(idx,idx+1,len(tmp)) + if i == tmp[idx+1]: + second = True + if second == False and first == False: + print("naughte cus no double") + for idx,i in enumerate(tmp): + if f.find(i) != -1 and second == True and first == False: + vowel_count += 1 + if vowel_count == 3: + print(" is nice because it contains " + str(vowel_count) + " vowels and double letters") + result += 1 + if second == True and vowel_count < 3: + print("naughty cus " + str(vowel_count) + " vowels") + print() +print(result)