Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # zoeken we antwoord A of B?
- vraag = 'B'
- # bestand lezen en in stukjes hakken:
- bestand = open('input.txt', 'r')
- alles = bestand.readlines()
- for x in range(len(alles)):
- alles[x] = alles[x].replace('\n', '')
- for x in range(10):
- alles[x] = list(alles[x])
- for y in range(10):
- for x in range(10):
- alles[y][x] = int(alles[y][x])
- if vraag == 'A':
- stappen = 100
- if vraag == 'B':
- stappen = 300
- omheen = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, +1], [1, -1], [1, 0], [1,1]]
- flitsen = 0
- asynchroon = True
- for stap in range(stappen):
- for y in range(10):
- for x in range(10):
- alles[y][x] += 1
- klaar = False
- while klaar == False:
- klaar = True
- for y in range(10):
- for x in range(10):
- if alles[y][x] != 'F':
- if alles[y][x] > 9:
- klaar = False
- alles[y][x] = 'F'
- flitsen += 1
- for z in range(8):
- if y+omheen[z][0] > -1 and y+omheen[z][0] < 10 and x+omheen[z][1] > -1 and x+omheen[z][1] < 10:
- if alles[y+omheen[z][0]][x+omheen[z][1]] != 'F':
- alles[y+omheen[z][0]][x+omheen[z][1]] += 1
- if asynchroon:
- tegelijk = True
- for y in range(10):
- for x in range(10):
- if alles[y][x] != 'F':
- tegelijk = False
- if tegelijk:
- asynchroon = False
- antwoordb = stap + 1
- for y in range(10):
- for x in range(10):
- if alles[y][x] == 'F':
- alles[y][x] = 0
- if vraag == 'A':
- print(flitsen)
- if vraag == 'B':
- print(antwoordb)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement