Advent-of-Code/2015/day 5/P2/string.py

19 lines
470 B
Python
Raw Normal View History

2019-12-01 17:44:00 +01:00
strings = open("input.txt").read().split("\n")[:-1]
nice = 0
for i in strings:
2019-12-02 08:18:26 +01:00
pair = False
2019-12-01 17:44:00 +01:00
double = False
for j in range(len(i)-1):
2019-12-02 08:18:26 +01:00
if not pair:
if i.count(f"{i[j]}{i[j+1]}") >= 2 and f"{i[j]}{i[j]}{i[j]}" not in i:
pair = True
if not double:
f2 = i.find(i[j], j+1)
if f2-j == 2:
double = True
if pair and double:
2019-12-01 17:44:00 +01:00
nice+=1
break
print(nice)