久々にYukicoderに出た.
回答
#75649 No.341 沈黙の期間 - yukicoder
最長マッチする文字列を検索する.Pythonの正規表現のライブラリの中に,findallというものがあり,これを使うとマッチした文字列のリストを取り出すことができる.
マッチした文字列のリストの要素に対して,一番長いものを求めてやると答えが出る.
参考
6.2. re — 正規表現操作 — Python 3.5.1 ドキュメント
import re def solve(): matchwords = re.findall(r"…+", input()) matchwords.append("") # if no match pattern print(max([len(s) for s in matchwords])) if __name__=="__main__": solve()