0
0
Fork 0

Add code for 2015 advent that I did historically.

This commit is contained in:
Oliver-Akins 2020-12-06 20:33:17 -07:00
parent 13968ed94e
commit 9e9e556c73
25 changed files with 598 additions and 0 deletions

21
day_5/part_2.py Normal file
View file

@ -0,0 +1,21 @@
import re
double_letter_pattern = r"(?P<chars>[A-Za-z]{2})\w*(?P=chars)"
triple_letter_pattern = r"(?P<chars>[A-Za-z])\w(?P=chars)"
def is_nice(string):
return (
re.search(double_letter_pattern, string) != None
and
re.search(triple_letter_pattern, string) != None
)
total_nice_lines = 0
data = open("input", "r")
for line in data:
if is_nice(line):
total_nice_lines += 1
data.close()
print(f"Total Nice Lines: {total_nice_lines}")