40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
#!/bin/python3
|
|
import sys,time,re
|
|
from pprint import pprint
|
|
from itertools import groupby
|
|
sys.path.insert(0, '../../')
|
|
from fred import list2int,get_re,nprint,lprint,loadFile
|
|
start_time = time.time()
|
|
|
|
input_f = 'input'
|
|
|
|
part = 1
|
|
#########################################
|
|
# #
|
|
# Part 1 #
|
|
# #
|
|
#########################################
|
|
|
|
if part == 1:
|
|
instructions = loadFile(input_f)[0]
|
|
print(instructions)
|
|
|
|
for i in range(0,50):
|
|
numbers = [(len(list(group)),key) for key, group in groupby(instructions)]
|
|
result = ''
|
|
for n in numbers:
|
|
result += str(n[0])+str(n[1])
|
|
#print(instructions,'->',result)
|
|
instructions = result
|
|
#input()
|
|
print(len(instructions))
|
|
|
|
#########################################
|
|
# #
|
|
# Part 2 #
|
|
# #
|
|
#########################################
|
|
if part == 2:
|
|
exit()
|
|
|
|
print("--- %s seconds ---" % (time.time() - start_time)) |