diff options
| author | David Ferrone <zapwai@gmail.com> | 2024-06-20 16:42:41 -0400 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2024-06-20 16:42:41 -0400 |
| commit | 8ef5ca339458a84020cb28e58aed50e18720b40b (patch) | |
| tree | 78c44541e20ad6c645f3ce4e01369c6b311b70ce /challenge-274/zapwai/python/ch-2.py | |
| parent | ffc47a8850ee877978e371d11a01a028862a3f9d (diff) | |
| download | perlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.tar.gz perlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.tar.bz2 perlweeklychallenge-club-8ef5ca339458a84020cb28e58aed50e18720b40b.zip | |
Week 274
Diffstat (limited to 'challenge-274/zapwai/python/ch-2.py')
| -rw-r--r-- | challenge-274/zapwai/python/ch-2.py | 32 |
1 files changed, 32 insertions, 0 deletions
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) |
