day 10 part 1
This commit is contained in:
1
09/i.py
1
09/i.py
@@ -1,5 +1,4 @@
|
||||
import os
|
||||
import math
|
||||
|
||||
input = open(os.path.dirname(__file__) +
|
||||
"/input.txt", "r").readlines()
|
||||
|
||||
30
10/j.py
Normal file
30
10/j.py
Normal 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))
|
||||
Reference in New Issue
Block a user