# Untitled

unknown
python
15 days ago
3.6 kB
9
Indexable
Never
```def generateAirPort(n):
airport = []
for i in range(n):
airportHorizontal = input()
airportHorizontal=[*airportHorizontal]
airport.append(airportHorizontal)
return(airport)

def findLongestRunway(airport):
longestRunway=0
counter=0
for y in range(len(airport)):
for x in range(len(airport)):
if airport[x][y]==".":
counter+=1
else:
if counter>longestRunway:
longestRunway=counter
counter=0
if counter > longestRunway:
longestRunway = counter
counter = 0
counter=0
for y in range(len(airport)):
for x in range(len(airport)):
if airport[y][x] == ".":
counter += 1
else:
if counter > longestRunway:
longestRunway = counter
counter=0
if counter > longestRunway:
longestRunway = counter
counter = 0
return longestRunway

def findRunwaysWithMaxCounter(airport,maxcounter):
runwayArray=[]
runway=[]
counter=0
for x in range(len(airport)):
if len(runway) > 0:
runway.append(counter)
counter = 0
runwayArray.append(runway)
# print(runway)
runway = []
for y in range(len(airport)):
if airport[x][y] == "." and counter < maxcounter:
counter += 1
runway.append([x, y])
else:
if len(runway) > 0:
runway.append(counter)
counter = 0
runwayArray.append(runway)
# print(runway)
runway = []
for x in range(len(airport)):
if len(runway) > 0:
runway.append(counter)
counter = 0
runwayArray.append(runway)
# print(runway)
runway = []
for y in range(len(airport)):
if airport[y][x] == "." and counter < maxcounter:
counter += 1
runway.append([y, x])
else:
if len(runway) > 0:
runway.append(counter)
counter = 0
runwayArray.append(runway)
# print(runway)
runway = []
return runwayArray
def findRunways(airport):
maxcounter=len(airport)
for i in range(len(airport)):
runwayArray=findRunwaysWithMaxCounter(airport,maxcounter)
longestRunways=[]
for runway in runwayArray:
if runway[-1] == maxcounter:
longestRunways.append(runway)
if(len(longestRunways)>=2):
print(longestRunways,maxcounter)
valid = True
for i in range(len(longestRunways)):
for j in range(len(longestRunways)):
for k in range(len(longestRunways[i])-1):
for l in range(len(longestRunways[j])-1):
if longestRunways[i][k]==longestRunways[j][l]:
valid=False
if valid:
return(maxcounter)
else:
valid=True
else:
maxcounter-=1
maxcounter -= 1

firstInput = input("")
firstInput = firstInput.split(" ")
n = int(firstInput[0])
m = int(firstInput[1])
if(m==1):
print(findLongestRunway(generateAirPort(n)))
else:
print(findRunways(generateAirPort(n)))
```