Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bestand inlezen:
- #bestand = open('voorbeeld.txt', 'r')
- bestand = open('input.txt', 'r')
- alles = bestand.readlines()
- for x in range(len(alles)):
- alles[x] = alles[x].replace('\n', '')
- antwoord = 0
- # kies een boom:
- for y in range(len(alles)):
- for x in range(len(alles[y])):
- #kijk naar links:
- zichtl = True
- for z in range(x):
- if alles[y][x-z-1] >= alles[y][x]:
- zichtl = False
- #kijk naar rechts:
- zichtr = True
- for z in range(len(alles[y])-x-1):
- if alles[y][x+z+1] >= alles[y][x]:
- zichtr = False
- #kijk naar boven:
- zichtb = True
- for z in range(y):
- if alles[y-z-1][x] >= alles[y][x]:
- zichtb = False
- # kijk naar onder:
- zichto = True
- for z in range(len(alles)-y-1):
- if alles[y+z+1][x] >= alles[y][x]:
- zichto = False
- #zichtbare bomen optellen:
- if zichtl or zichtr or zichtb or zichto:
- antwoord += 1
- #antwoord A:
- print(antwoord)
- antwoord2 = 0
- # kies een boom:
- for y in range(len(alles)):
- for x in range(len(alles[y])):
- #kijk naar links:
- zichtl = True
- links = 0
- for z in range(x):
- if alles[y][x-z-1] >= alles[y][x]:
- if zichtl:
- links = z+1
- zichtl = False
- if zichtl:
- links = z+1
- #kijk naar rechts:
- zichtr = True
- rechts = 0
- for z in range(len(alles[y])-x-1):
- if alles[y][x+z+1] >= alles[y][x]:
- if zichtr:
- rechts = z+1
- zichtr = False
- if zichtr:
- rechts = z+1
- #kijk naar boven:
- zichtb = True
- boven = 0
- for z in range(y):
- if alles[y-z-1][x] >= alles[y][x]:
- if zichtb:
- boven = z+1
- zichtb = False
- if zichtb:
- boven = z+1
- # kijk naar onder:
- zichto = True
- onder = 0
- for z in range(len(alles)-y-1):
- if alles[y+z+1][x] >= alles[y][x]:
- if zichto:
- onder = z+1
- zichto = False
- if zichto:
- onder = z+1
- # score uitrekenen:
- score = links*rechts*boven*onder
- if score > antwoord2:
- antwoord2 = score
- print(antwoord2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement