Zadanie A03
This commit is contained in:
parent
07c719be98
commit
d0af982a3e
45
TaskA03/A03.py
Normal file
45
TaskA03/A03.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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"))
|
2
TaskA03/run
Executable file
2
TaskA03/run
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
python3 TaskA03/A03.py "$@"
|
Loading…
Reference in New Issue
Block a user