Prześlij pliki do 'TaskA03'
This commit is contained in:
parent
19383470b9
commit
45163cade7
6
TaskA03/description.txt
Normal file
6
TaskA03/description.txt
Normal file
@ -0,0 +1,6 @@
|
||||
Write a program to find lines containing date from 1900 to 1999 in format '19XX r.' no matter what on the left or right of the expression.
|
||||
Note that part ' r.' is obligatory.
|
||||
Do not use regular expressions, just the simplest capabilities
|
||||
of a programming language.
|
||||
|
||||
POINTS: 2
|
951
TaskA03/polish_wiki_excerpt.exp
Normal file
951
TaskA03/polish_wiki_excerpt.exp
Normal file
File diff suppressed because one or more lines are too long
BIN
TaskA03/polish_wiki_excerpt.in
Normal file
BIN
TaskA03/polish_wiki_excerpt.in
Normal file
Binary file not shown.
51
TaskA03/run.py
Normal file
51
TaskA03/run.py
Normal file
@ -0,0 +1,51 @@
|
||||
def checkDigit(char):
|
||||
digits=['1','2','3','4','5','6','7','8','9']
|
||||
for j in range(len(digits)):
|
||||
if char==digits[j]:
|
||||
return char
|
||||
return None
|
||||
|
||||
def checkYear(file):
|
||||
with open(file, "r", encoding="utf-8") as sampleCheck:
|
||||
line = 0
|
||||
lineCount = 0
|
||||
flag =0
|
||||
for row in sampleCheck:
|
||||
line += 1
|
||||
date = ''
|
||||
for char in row.lower():
|
||||
if char=='1':
|
||||
flag = 1
|
||||
date += char
|
||||
elif flag==1 and char=='9':
|
||||
flag=2
|
||||
date += char
|
||||
elif flag==2 and char==checkDigit(char):
|
||||
flag=3
|
||||
date += char
|
||||
elif flag==3 and char==checkDigit(char):
|
||||
flag=4
|
||||
date += char
|
||||
elif flag==4 and char==' ':
|
||||
flag=5
|
||||
date+=char
|
||||
elif flag==5 and char=='r':
|
||||
flag=6
|
||||
date+=char
|
||||
elif flag==6 and char=='.':
|
||||
flag=7
|
||||
date+=char
|
||||
if flag==7:
|
||||
flag =0
|
||||
date=''
|
||||
print(line)
|
||||
file = 'simple.in'
|
||||
checkYear(file)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
3
TaskA03/simple.exp
Normal file
3
TaskA03/simple.exp
Normal file
@ -0,0 +1,3 @@
|
||||
Kiedyś był 1934 r.
|
||||
Kiedyś był 1934 r.fsdfsdfsdf
|
||||
1934 r. to jakaś data
|
Loading…
Reference in New Issue
Block a user