p1/02_sikaniranje/naloga.py
Gašper Dobrovoljc 3a09b99dfa
03_zemljevid_ovir
2023-10-27 12:49:52 +02:00

37 lines
745 B
Python

ovire = [(1, 3, 6), (2, 4, 3), (4, 6, 7), (3, 4, 9), (6, 9, 5), (9, 10, 2), (9, 10, 8)]
x = 6
min_y = None
for x1, x2, y in ovire:
if x >= x1 and x <= x2 and (min_y == None or min_y > y):
min_y = y
print(min_y)
# Dodatna naloga
ovire = [(1, 3, 6), (2, 4, 3), (4, 6, 7), (3, 4, 9), (6, 9, 5), (9, 10, 2), (9, 10, 8)]
sirina = 0
for x1, x2, y in ovire:
if x2 > sirina:
sirina = x2
max_x = 0
max_y = 0
for x in range(1, sirina+1):
min_y = None
for x1, x2, y in ovire:
if x >= x1 and x <= x2 and (min_y == None or min_y > y):
min_y = y
if min_y == None:
print(x, "Zmaga!")
break
if max_y < min_y:
max_y = min_y
max_x = x
else:
print(max_x, max_y)