2023-10-27 10:49:52 +00:00
|
|
|
def dolzina_ovir(vrstica):
|
2023-11-16 15:18:51 +00:00
|
|
|
return vrstica.count("#")
|
2023-10-27 10:49:52 +00:00
|
|
|
|
|
|
|
def stevilo_ovir(vrstica):
|
|
|
|
count = 0
|
|
|
|
ovira = False
|
2023-11-09 20:58:58 +00:00
|
|
|
|
2023-10-27 10:49:52 +00:00
|
|
|
for char in vrstica:
|
|
|
|
if char == "#":
|
2023-11-09 20:58:58 +00:00
|
|
|
ovira = True
|
2023-10-27 10:49:52 +00:00
|
|
|
elif ovira:
|
|
|
|
count += 1
|
|
|
|
ovira = False
|
|
|
|
if ovira:
|
|
|
|
count += 1
|
|
|
|
return count
|
|
|
|
|
|
|
|
def najsirsa_ovira(vrstica):
|
|
|
|
sirina_max = 0
|
|
|
|
sirina = 0
|
|
|
|
for char in vrstica:
|
|
|
|
if char == "#":
|
|
|
|
sirina += 1
|
|
|
|
else:
|
|
|
|
if sirina > sirina_max:
|
|
|
|
sirina_max = sirina
|
|
|
|
sirina = 0
|
|
|
|
if sirina > sirina_max:
|
|
|
|
sirina_max = sirina
|
|
|
|
return sirina_max
|
|
|
|
|
|
|
|
def pretvori_vrstico(vrstica):
|
|
|
|
ovire = []
|
|
|
|
ovira = False
|
|
|
|
start = 0
|
|
|
|
for i, char in enumerate(vrstica):
|
|
|
|
if char == "#":
|
|
|
|
if not ovira:
|
|
|
|
start = i + 1
|
|
|
|
ovira = True
|
|
|
|
elif ovira:
|
|
|
|
ovire.append((start, i))
|
|
|
|
ovira = False
|
|
|
|
if ovira:
|
|
|
|
ovire.append((start, i + 1))
|
|
|
|
return ovire
|
|
|
|
|
|
|
|
def pretvori_zemljevid(vrstice):
|
|
|
|
ovire = []
|
|
|
|
for y, vrstica in enumerate(vrstice, start=1):
|
|
|
|
for ovira in pretvori_vrstico(vrstica):
|
|
|
|
ovire.append((*ovira, y))
|
|
|
|
return ovire
|
2023-11-09 20:58:58 +00:00
|
|
|
|
2023-10-27 10:49:52 +00:00
|
|
|
def izboljsave(prej, potem):
|
|
|
|
nove_ovire = []
|
|
|
|
star_zemljevid = pretvori_zemljevid(prej)
|
|
|
|
for ovira in pretvori_zemljevid(potem):
|
|
|
|
if ovira not in star_zemljevid:
|
|
|
|
nove_ovire.append(ovira)
|
|
|
|
return nove_ovire
|
|
|
|
|
|
|
|
def huligani(prej, potem):
|
|
|
|
dodane_ovire = []
|
|
|
|
odstranjene_ovire = []
|
|
|
|
|
|
|
|
star_zemljevid = pretvori_zemljevid(prej)
|
|
|
|
nov_zemljevid = pretvori_zemljevid(potem)
|
|
|
|
|
|
|
|
for ovira in star_zemljevid:
|
|
|
|
if ovira not in nov_zemljevid:
|
|
|
|
odstranjene_ovire.append(ovira)
|
|
|
|
|
|
|
|
for ovira in nov_zemljevid:
|
|
|
|
if ovira not in star_zemljevid:
|
|
|
|
dodane_ovire.append(ovira)
|
|
|
|
|
|
|
|
return dodane_ovire, odstranjene_ovire
|