day 6, easy peazy

This commit is contained in:
setop 2023-12-06 10:01:43 +01:00
parent 2ae942085d
commit 69c8d0f72c
2 changed files with 40 additions and 0 deletions

30
d06/part1.py Normal file
View File

@ -0,0 +1,30 @@
SAMPLE = [
#Time: Distance:
(7, 9),
(15, 40),
(30, 200),
]
INPUT = [
(40, 219),
(81, 1012),
(77, 1365),
(72, 1089),
]
L = SAMPLE
L=INPUT
R = 1
for (t,r) in L: # time, record
S = 0
for i in range(t): # hold for i
v = i # speed in m/s
d = v * (t-i)
if d > r:
S += 1
print(S)
R *= S
print(R)

10
d06/part2.py Normal file
View File

@ -0,0 +1,10 @@
import sys
(t,r) = (int(sys.argv[1]), int(sys.argv[2]))
print(
# i : time of charging, between 0 and t
# v = i # speed in m/s
# d = v * (t-i) # distance
sum(i*(t-i) > r for i in range(t))
)