Litt langt, men fungerende forslag til luke 15.

This commit is contained in:
2017-12-16 19:12:50 +01:00
parent cdadf79f30
commit 37a3ab01c5

22
luke_15/trekutting.py Executable file
View File

@@ -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()