Dodanie D-Task

This commit is contained in:
Polevara Veronika 2023-11-25 15:59:13 +01:00
parent 98bcfdea83
commit ed4c60e3ec
20 changed files with 127 additions and 0 deletions

5
TaskD01/description.txt Normal file
View File

@ -0,0 +1,5 @@
Write a program to find lines containing the word "Hamlet".
Do use regular expressions.
POINTS: 1
DEADLINE: 2023-11-26 23:59:59

13
TaskD01/run.py Normal file
View File

@ -0,0 +1,13 @@
import re
import sys
found_lines = []
for line in sys.stdin:
if re.search(r'\bHamlet\b', line):
found_lines.append(line.strip())
if found_lines:
print('\n'.join(found_lines), end='')

2
TaskD01/simple.exp Normal file
View File

@ -0,0 +1,2 @@
Here comes Hamlet
Hamlet Hamlet again

3
TaskD01/simple.in Normal file
View File

@ -0,0 +1,3 @@
Here comes Hamlet
ABC
Hamlet Hamlet again

2
TaskD01/simple.out Normal file
View File

@ -0,0 +1,2 @@
Here comes Hamlet
Hamlet Hamlet again

7
TaskD02/description.txt Normal file
View File

@ -0,0 +1,7 @@
Write a program to find lines containing the word "pies" separated by spaces.
The word does not need to have space on the left if it is the line beginning or space on the right if it is line ending.
Return line no matter of word "pies" casing.
Do use regular expressions.
POINTS: 1
DEADLINE: 2023-11-26 23:59:59

13
TaskD02/run.py Normal file
View File

@ -0,0 +1,13 @@
import re
import sys
found_lines = []
for line in sys.stdin:
if re.search(r'\b\s*pies\s*\b', line, flags=re.IGNORECASE):
found_lines.append(line.strip())
if found_lines:
print('\n'.join(found_lines), end='')

3
TaskD02/simple.exp Normal file
View File

@ -0,0 +1,3 @@
Pies ma Ale
Kot i pies to zwierzeta
pies

5
TaskD02/simple.in Normal file
View File

@ -0,0 +1,5 @@
Pies ma Ale
Ala ma psa
tu nic nie ma
Kot i pies to zwierzeta
pies

3
TaskD02/simple.out Normal file
View File

@ -0,0 +1,3 @@
Pies ma Ale
Kot i pies to zwierzeta
pies

6
TaskD03/description.txt Normal file
View 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 use regular expressions.
POINTS: 1
DEADLINE: 2023-11-26 23:59:59

14
TaskD03/run.py Normal file
View File

@ -0,0 +1,14 @@
import re
import sys
found_lines = []
for line in sys.stdin:
if re.search(r'\b19\d{2}\s*r\.\b|\b\W19\d{2}\s*r\.\b|\b19\d{2}\s*r\.\W', line, flags=re.IGNORECASE):
found_lines.append(line.strip())
if found_lines:
print('\n'.join(found_lines), end='')

3
TaskD03/simple.exp Normal file
View File

@ -0,0 +1,3 @@
Kiedys byl 1934 r.
Kiedys byl 1934 r.fsdfsdfsdf
1934 r. to jakas data

5
TaskD03/simple.in Normal file
View File

@ -0,0 +1,5 @@
Kiedys byl 1934 r.
Kiedys byl 1934 r.fsdfsdfsdf
Kiedys byl 1935 rok
1934 r. to jakas data
1934 to tez jakas data

3
TaskD03/simple.out Normal file
View File

@ -0,0 +1,3 @@
Kiedys byl 1934 r.
Kiedys byl 1934 r.fsdfsdfsdf
1934 r. to jakas data

6
TaskD04/description.txt Normal file
View File

@ -0,0 +1,6 @@
Write a program to find all maximum substrings of digits.
Return only these substrings separated by spaces in their order.
Do use regular expressions.
POINTS: 2
DEADLINE: 2023-11-26 23:59:59

21
TaskD04/run.py Normal file
View File

@ -0,0 +1,21 @@
import re
import sys
def remove_non_digits(line):
return re.sub(r'[^0-9\s]', '', line)
processed_lines = []
for line in sys.stdin:
processed_line = remove_non_digits(line)
processed_line = re.sub(r'^\s+|\s+$', '', processed_line)
processed_line = re.sub(r'\s+', ' ', processed_line)
digit_groups = re.findall(r'\d+', processed_line)
if digit_groups:
processed_lines.append(' '.join(digit_groups))
print('\n'.join(processed_lines), end='')

4
TaskD04/simple.exp Normal file
View File

@ -0,0 +1,4 @@
34234 34 5
34535
34
1992 1999

5
TaskD04/simple.in Normal file
View File

@ -0,0 +1,5 @@
34234 34 dfd gfd 5
34535
fsdflskfjsdflk
fsdkfj sdf34fdfd
The company was established in 1992 from the merger of Authorware, Inc. (creators of the Authorware package) and MacroMind-Paracomp (producer of Macromind Director). In 1999, Macromedia purchased Allaire and its bi

4
TaskD04/simple.out Normal file
View File

@ -0,0 +1,4 @@
34234 34 5
34535
34
1992 1999