From 69c8d0f72ce0188e28ecbb4f5710a2a455e35a31 Mon Sep 17 00:00:00 2001 From: setop Date: Wed, 6 Dec 2023 10:01:43 +0100 Subject: [PATCH] day 6, easy peazy --- d06/part1.py | 30 ++++++++++++++++++++++++++++++ d06/part2.py | 10 ++++++++++ 2 files changed, 40 insertions(+) create mode 100644 d06/part1.py create mode 100644 d06/part2.py 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)) +)