scripts/ege/2.py

24 lines
505 B
Python
Raw Normal View History

2023-05-05 00:45:01 +03:00
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)