From 21944b2c8f61b8caf0d1a51cfd6d6b47325f1805 Mon Sep 17 00:00:00 2001 From: Frederik Baerentsen Date: Fri, 15 Dec 2023 14:38:52 -0500 Subject: [PATCH] Finished 2023-12-15 p1 --- 2023/day15/part1.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 2023/day15/part1.py diff --git a/2023/day15/part1.py b/2023/day15/part1.py new file mode 100644 index 0000000..fa30795 --- /dev/null +++ b/2023/day15/part1.py @@ -0,0 +1,40 @@ +import sys +import os +from pprint import pprint +import time +import math + +#colors +from termcolor import colored + +grid = [] + +input_f = '' +if len(sys.argv) == 1: + input_f = 'test' +else: + input_f = sys.argv[1] + +with open(input_f) as file: + for line in file: + grid = line.rstrip().split(',') + +print(grid) +values = [] +current_value = 0 + +for i in grid: + value = 0 + for j in list(i): + current_value += value + #print(j) + current_value += ord(j) + current_value *= 17 + current_value %= 256 + #print(current_value) + value = current_value + current_value = 0 + print(value) + values.append(value) + +print(sum(values)) \ No newline at end of file