From 8ef5ca339458a84020cb28e58aed50e18720b40b Mon Sep 17 00:00:00 2001 From: David Ferrone Date: Thu, 20 Jun 2024 16:42:41 -0400 Subject: Week 274 --- challenge-274/zapwai/python/ch-2.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 challenge-274/zapwai/python/ch-2.py (limited to 'challenge-274/zapwai/python/ch-2.py') diff --git a/challenge-274/zapwai/python/ch-2.py b/challenge-274/zapwai/python/ch-2.py new file mode 100644 index 0000000000..cef432da13 --- /dev/null +++ b/challenge-274/zapwai/python/ch-2.py @@ -0,0 +1,32 @@ +def delta(t, ran): + for r in (ran): + if r < t: + continue + return r - t + return 0 +inp = [ [12, 11, 41], [15, 5, 35] ] +MAX = 60 +R = [] +cost = [] +for l in inp: + interval = l[0] + start = l[1] + cost.append(l[2]) + L = [] + for i in range(int(MAX/l[0])): + x = start + i*interval + L.append(x) + R.append(L) +r1 = R[0] +r2 = R[1] +length_one = cost[0] +length_two = cost[1] +out = "" +for t in range(1, MAX-1): + delta_one = delta(t, r1) + delta_two = delta(t, r2) + time_taken_one = length_one + delta_one + time_taken_two = length_two + delta_two + if (delta_one < delta_two) and (time_taken_one > time_taken_two): + out += str(t)+" " +print(out) -- cgit