54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
|
#!/bin/python3
|
||
|
import sys,re
|
||
|
from pprint import pprint
|
||
|
|
||
|
input_f = 'test'
|
||
|
|
||
|
part = 1
|
||
|
#########################################
|
||
|
# #
|
||
|
# Part 1 #
|
||
|
# #
|
||
|
#########################################
|
||
|
|
||
|
if part == 1:
|
||
|
with open(input_f) as file:
|
||
|
for line in file:
|
||
|
print(line.rstrip())
|
||
|
clean_string = re.sub(r"!.", "", line.rstrip())
|
||
|
clean_string = re.sub(r"<.*?>", "", clean_string)
|
||
|
clean_string = re.sub(r",", "", clean_string)
|
||
|
#print(clean_string)
|
||
|
|
||
|
count = 1
|
||
|
score = 0
|
||
|
iteration = 0
|
||
|
#print('Score of ',end='')
|
||
|
while True:
|
||
|
#print('Iteration: ', iteration)
|
||
|
matches = re.findall(r"\{\}", clean_string)
|
||
|
if not matches:
|
||
|
#print(increment,end='')
|
||
|
print('=',score)
|
||
|
break
|
||
|
|
||
|
|
||
|
|
||
|
clean_string = re.sub(r"\{\}", "", clean_string)
|
||
|
iteration += 1
|
||
|
for x in range(0,len(matches)):
|
||
|
score += iteration
|
||
|
print(iteration,end="")
|
||
|
|
||
|
|
||
|
#print(clean_string)
|
||
|
#rint(count)
|
||
|
input()
|
||
|
#########################################
|
||
|
# #
|
||
|
# Part 2 #
|
||
|
# #
|
||
|
#########################################
|
||
|
if part == 2:
|
||
|
exit()
|