From eadc405a0ffd4daeeca9c7bdfb993bd9de5676a4 Mon Sep 17 00:00:00 2001 From: Mika Suhonen Date: Sat, 10 Dec 2022 07:42:27 +0200 Subject: [PATCH] day 10 part 1 --- 09/i.py | 1 - 10/j.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 10/j.py diff --git a/09/i.py b/09/i.py index d9793da..d3e4935 100644 --- a/09/i.py +++ b/09/i.py @@ -1,5 +1,4 @@ import os -import math input = open(os.path.dirname(__file__) + "/input.txt", "r").readlines() diff --git a/10/j.py b/10/j.py new file mode 100644 index 0000000..f78617d --- /dev/null +++ b/10/j.py @@ -0,0 +1,30 @@ +import os + +input = open(os.path.dirname(__file__) + + "/input.txt", "r").readlines() + +cost = { + 'noop': 1, + 'addx': 2 +} + +cycle = 1 +l = 0 +finish = len(input) +X = 1 +strs = [] + +for l in input: + cmd = l.split() + for i in range(cost[cmd[0]]): + #print(cycle, X, strs) + + if ((cycle+20) % 40) == 0: + strenth = cycle*X + # print(">> " + str(cycle) + " " + str(strenth)) + strs.append(strenth) + cycle += 1 + if cmd[0] == 'addx': + X += int(cmd[1]) + +print(sum(strs))