scripts/ege/2.py
2023-05-05 00:45:01 +03:00

24 lines
505 B
Python

with open("24.txt") as f:
data = f.read()
data = data.split("F")
mx = 0
mf = ""
for i in range(len(data)):
if data[i] and data[i].count("A") <= 2:
p = []
j = i + 1
try:
while data[j].count("A") <= 2:
p.append(data[j])
j += 1
s = "F" + "F".join(p) + "F"
if len(s) > mx:
mx = len(s)
mf = s
except IndexError:
break
print(mx, mf)