day 10 part 1

This commit is contained in:
2022-12-10 07:42:27 +02:00
parent aac89964d2
commit eadc405a0f
2 changed files with 30 additions and 1 deletions

View File

@@ -1,5 +1,4 @@
import os
import math
input = open(os.path.dirname(__file__) +
"/input.txt", "r").readlines()

30
10/j.py Normal file
View File

@@ -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))