First solve of door nr 5.

This commit is contained in:
2017-12-05 10:39:26 +01:00
parent b58227846f
commit f423fe3cb5

38
luke_5/gullrekka.py Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# @Author: KevinMidboe
# @Date: 2017-12-04 16:40:56
# @Last Modified by: KevinMidboe
# @Last Modified time: 2017-12-05 10:36:22
total_loops = 0
def iterate(gold_row, num):
global total_loops
try:
countdown = gold_row[num-1]
except IndexError:
countdown = num
tmp = []
while countdown >= 1:
tmp.append(num)
countdown -=1
total_loops +=1
if (total_loops >= 1000000):
return tmp
return tmp
def main():
global total_loops
gold_row = []
i = 1
while total_loops < 1000000:
gold_row.extend(iterate(gold_row, i))
i +=1
print('Finished with million iterations')
print(sum(gold_row))
if __name__ == '__main__':
main()