AdventOfCode/2015/08/solution.py

45 lines
935 B
Python
Raw Normal View History

2024-12-05 23:13:04 +01:00
#!/bin/python3
2024-12-06 17:44:30 +01:00
import sys,re,ast,json
2024-12-05 23:13:04 +01:00
from pprint import pprint
sys.path.insert(0, '../../')
from fred import list2int,get_re,nprint,lprint,loadFile
2024-12-06 17:44:30 +01:00
input_f = 'input'
2024-12-05 23:13:04 +01:00
2024-12-06 17:44:30 +01:00
part = 2
2024-12-05 23:13:04 +01:00
#########################################
# #
# Part 1 #
# #
#########################################
if part == 1:
instructions = loadFile(input_f)
2024-12-06 17:44:30 +01:00
2024-12-05 23:13:04 +01:00
total = 0
2024-12-06 17:44:30 +01:00
2024-12-05 23:13:04 +01:00
for i in instructions:
2024-12-06 17:44:30 +01:00
total += (len(i)-len(ast.literal_eval(i)))
2024-12-05 23:13:04 +01:00
print(total)
#########################################
# #
# Part 2 #
# #
#########################################
if part == 2:
2024-12-06 17:44:30 +01:00
instructions = loadFile(input_f)
total = 0
for i in instructions:
total += (len(json.dumps(i)) - len(i))
print(total)