From 37a3ab01c5a5628a9a69593b8bafd026611784c7 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Sat, 16 Dec 2017 19:12:50 +0100 Subject: [PATCH] Litt langt, men fungerende forslag til luke 15. --- luke_15/trekutting.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 luke_15/trekutting.py diff --git a/luke_15/trekutting.py b/luke_15/trekutting.py new file mode 100755 index 0000000..fb9a83a --- /dev/null +++ b/luke_15/trekutting.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3.6 + +def main(): + trees = [23, 74, 26, 23, 92, 92, 44, 13, 34, 23, 69, 4, 19, 94, 94, 38, 14, 9, 51, 98, 72, 46, 17, 25, 21, 87, 99, 50, 59, 53, 82, 24, 93, 16, 88, 52, 14, 38, 27, 7, 18, 81, 13, 75, 80, 11, 29, 39, 37, 78, 55, 17, 78, 12, 77, 84, 63, 29, 68, 32, 17, 55, 31, 30, 3, 17, 99, 6, 45, 81, 75, 31, 50, 93, 66, 98, 94, 59, 68, 30, 98, 57, 83, 75, 68, 85, 98, 76, 91, 23, 53, 42, 72, 77] + trees_cut = [] + while True: + try: + cut_length = min(x for x in trees if x > 0) + except ValueError: + break + + counter = 0 + for i, tree in enumerate(trees): + if (trees[i] > 0): + trees[i] = tree - cut_length + counter += 1 + trees_cut.append(counter) + + return trees_cut + +if __name__ == '__main__': + main() \ No newline at end of file