diff --git a/d06/part1.py b/d06/part1.py new file mode 100644 index 0000000..7c8ecd7 --- /dev/null +++ b/d06/part1.py @@ -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) \ No newline at end of file diff --git a/d06/part2.py b/d06/part2.py new file mode 100644 index 0000000..e3e49a8 --- /dev/null +++ b/d06/part2.py @@ -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)) +)