Løsning på luke 16, ikke den raskeste, men finner minste hvis telleren er nummer 1.

This commit is contained in:
2017-12-16 12:52:02 +01:00
parent fa6e69e5d5
commit 2ef3df1ec4
2 changed files with 14400 additions and 0 deletions

33
luke_16/grinchen.py Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3.6
import os
def readFile():
with open(os.path.dirname(__file__) + '/hjelpere.txt', 'r') as hjelpere:
read_data = hjelpere.read().splitlines()
hjelpere.close()
return read_data
def main():
entry_list = readFile()
highest_value = []
light_state = False
memory = [False for i in range(100)]
counter = 0
for i, entry in enumerate(entry_list):
entry = int(entry)-1
if entry == 0 and light_state:
counter += 1
light_state = False
if (counter >= 99):
highest_value.append(i)
else:
if memory[entry] == False and light_state == False:
memory[entry] = True
light_state = True
print(min(highest_value)+1)
if __name__ == '__main__':
main()

14367
luke_16/hjelpere.txt Normal file

File diff suppressed because it is too large Load Diff