46 lines
973 B
Python
46 lines
973 B
Python
|
import sys
|
||
|
|
||
|
|
||
|
def check_date(word):
|
||
|
try:
|
||
|
date = int(word)
|
||
|
if 1900 <= int(date) <= 1999:
|
||
|
return True
|
||
|
else:
|
||
|
return False
|
||
|
except ValueError:
|
||
|
return False
|
||
|
|
||
|
|
||
|
def check_words(words):
|
||
|
all_dates = []
|
||
|
for word in words:
|
||
|
if check_date(word):
|
||
|
all_dates.append(word)
|
||
|
return all_dates
|
||
|
|
||
|
|
||
|
def contains_date(line):
|
||
|
formatted_line = line.lower()
|
||
|
words = formatted_line.split()
|
||
|
for word in words:
|
||
|
if '.' in word:
|
||
|
words.extend(word.split('.'))
|
||
|
if '(' in word:
|
||
|
words.extend(word.split('('))
|
||
|
if ')' in word:
|
||
|
words.extend(word.split(')'))
|
||
|
checked_dates = check_words(words)
|
||
|
for date in checked_dates:
|
||
|
if checked_dates:
|
||
|
if date + ' r.' in formatted_line:
|
||
|
return line
|
||
|
|
||
|
else:
|
||
|
return False
|
||
|
|
||
|
|
||
|
for line in sys.stdin:
|
||
|
if contains_date(line):
|
||
|
print(line.rstrip("\n"))
|