Compare commits

...

9 Commits

Author SHA1 Message Date
Pawel Felcyn da203c4b6f f 2024-01-21 21:43:56 +01:00
Pawel Felcyn 9081d592a0 Merge remote-tracking branch 'wmi_upstream/main' 2024-01-08 14:15:57 +01:00
Pawel Felcyn 53ac53201c e 2024-01-08 14:14:27 +01:00
Jacek Kałużny dc0392f7d6
Delete TaskG04 directory 2024-01-08 13:58:09 +01:00
Jacek Kałużny ae508b36b1
Update description.txt 2024-01-08 13:56:18 +01:00
Jacek Kałużny cd6b06cefa
Update description.txt 2024-01-08 13:55:58 +01:00
Jacek Kałużny c818e6742f
Update description.txt 2024-01-08 13:55:38 +01:00
Jacek Kałużny 6b53fddd75
Update description.txt 2024-01-08 13:54:44 +01:00
Jacek Kałużny 8fb54512d7
Add files via upload 2024-01-08 11:27:35 +01:00
25 changed files with 89482 additions and 10 deletions

18
TaskE08/run.py Normal file
View File

@ -0,0 +1,18 @@
import re
def check_number_divisible_by_5(input_string):
pattern = r'^(hi){2,}\!*$'
if re.match(pattern, input_string):
print('yes')
else:
print('no')
if __name__ == "__main__":
try:
while True:
line = input()
check_number_divisible_by_5(line)
except EOFError:
pass

18
TaskE09/run.py Normal file
View File

@ -0,0 +1,18 @@
import re
def check_number_divisible_by_5(input_string):
pattern = r'.*[A-Z]\d{2}.*'
if re.match(pattern, input_string):
print('yes')
else:
print('no')
if __name__ == "__main__":
try:
while True:
line = input()
check_number_divisible_by_5(line)
except EOFError:
pass

18
TaskE12/run.py Normal file
View File

@ -0,0 +1,18 @@
import re
def check_number_divisible_by_5(input_string):
pattern = r'^(?!1-500-56773-4323)\d-\d{3}-\d{5}-\d{4}$'
if re.match(pattern, input_string):
print('yes')
else:
print('no')
if __name__ == "__main__":
try:
while True:
line = input()
check_number_divisible_by_5(line)
except EOFError:
pass

18
TaskE19/run.py Normal file
View File

@ -0,0 +1,18 @@
import re
def check_number_divisible_by_5(input_string):
pattern = r'^1(00)+$'
if re.match(pattern, input_string):
print('yes')
else:
print('no')
if __name__ == "__main__":
try:
while True:
line = input()
check_number_divisible_by_5(line)
except EOFError:
pass

18
TaskF00/run.py Normal file
View File

@ -0,0 +1,18 @@
import re
def substitute_digits(match):
digit_mapping = {'0': 'a', '1': 'b', '2': 'c', '3': 'd', '4': 'e', '5': 'f', '6': 'g', '7': 'h', '8': 'i', '9': 'j'}
return ''.join([digit_mapping[d] for d in match.group()])
if __name__ == "__main__":
while True:
try:
line = input()
if not line:
break
result = re.sub(r'\b\d{4}\b', substitute_digits, line)
print(result)
except EOFError:
break

View File

@ -18,5 +18,3 @@ letter to lower. In this task word means the string of "\w" metacharacters,
lower case letter is [a-ząćęłńóśźż] class,
capital case letter is [A-ZĄĆĘŁŃÓŚŹŻ] class.
POINTS: 2
DEADLINE: 2020-12-18 23:59:59

17
TaskF01/run.py Normal file
View File

@ -0,0 +1,17 @@
import re
def swap_case(match):
return match.group().swapcase()
if __name__ == "__main__":
while True:
try:
line = input()
if not line:
break
result = re.sub(r'\b(?=\w*[a-ząćęłńóśźż])(?=\w*[A-ZĄĆĘŁŃÓŚŹŻ])\w+\b', swap_case, line)
print(result)
except EOFError:
break

23
TaskF02/run.py Normal file
View File

@ -0,0 +1,23 @@
import re
def count_characters(category, line):
return len(re.findall(category, line))
if __name__ == "__main__":
while True:
try:
line = input()
if not line:
break
# Zliczanie małych liter, dużych liter, cyfr i pozostałych znaków osobno
lowercase_count = count_characters(r'[a-ząćęłńóśźż]', line)
uppercase_count = count_characters(r'[A-ZĄĆĘŁŃÓŚŹŻ]', line)
digit_count = count_characters(r'\d', line)
other_count = count_characters(r'[^a-ząćęłńóśźżA-ZĄĆĘŁŃÓŚŹŻ\d]', line)
result = f"{lowercase_count} {uppercase_count} {digit_count} {other_count}"
print(result)
except EOFError:
break

View File

@ -19,6 +19,3 @@ In this task word means a string of "\w" metacharacters,
lower case letter is [a-ząćęłńóśźż] class,
capital case letter is [A-ZĄĆĘŁŃÓŚŹŻ] class capital case letter is [A-ZĄĆĘŁŃÓŚŹŻ] class.
POINTS: 1
DEADLINE: 2020-12-18 23:59:59

20
TaskF03/run.py Normal file
View File

@ -0,0 +1,20 @@
import re
def count_characters(category, line):
return len(re.findall(category, line))
if __name__ == "__main__":
while True:
try:
line = input()
if not line:
break
lowercase_count = count_characters(r'\b[a-ząćęłńóśźż]\w*\b', line)
uppercase_count = count_characters(r'\b[A-ZĄĆĘŁŃÓŚŹŻ]\w*\b', line)
result = f"{lowercase_count} {uppercase_count}"
print(result)
except EOFError:
break

View File

@ -16,5 +16,3 @@ Write the input line with the second digits string deleted.
Digit is a [0-9] class.
POINTS: 1
DEADLINE: 2020-12-18 23:59:59

View File

@ -17,6 +17,3 @@ The number of "x" in the "xxx" string should be the same as the
the number of characters in the input string.
In this task, a word means a string of "\w" metacharacters.
POINTS: 2
DEADLINE: 2020-12-18 23:59:59

14
TaskF05/run.py Normal file
View File

@ -0,0 +1,14 @@
import re
if __name__ == "__main__":
while True:
try:
line = input()
if not line:
break
result = re.sub(r'(\b\w+\b) (\b\w+\b) (\b\w+\b)', lambda match: f'{match.group(1)} {match.group(2)} {"x" * len(match.group(3))}', line)
print(result)
except EOFError:
break

20
TaskG00/description.txt Normal file
View File

@ -0,0 +1,20 @@
Use regular expressions to extract lines containing polish surnames.
Download list of polish male and female surnames from here:
* https://dane.gov.pl/pl/dataset/1681,nazwiska-osob-zyjacych-wystepujace-w-rejestrze-pesel/resource/35279/table?page=1&per_page=20&q=&sort=
* https://dane.gov.pl/pl/dataset/1681,nazwiska-osob-zyjacych-wystepujace-w-rejestrze-pesel/resource/22817/table?page=1&per_page=20&q=&sort=
Extract lines from stdin containing any of the surnames.
Look only for surnames in lowercase.
The surname does not have to be surrounded by space or any other special characters.
Don't search for declined forms of surnames.
Check either NFA (e.g. re python library) and DFA (google re2) and compare run speed.
Submit solution based on DFA library.
NOTE: You could extract the polish surnames list, save it to a file, then commit the file to your repository.
NOTE: You may set max_mem to a higher value than the default in re2 library.

File diff suppressed because one or more lines are too long

View File

41
TaskG01/description.txt Normal file
View File

@ -0,0 +1,41 @@
Use regular expressions to mark Polish first-person masculine forms.
You should handle the following types of expressions:
* first-person masculine past forms of verbs ("zrobiłem", "pisałem", etc.),
* first-person singular masculine forms of the verb "być" ("be") combined
with singular masculine nominative forms of adjectives ("wysoki", "sprytny", etc.),
assuming that the form of the verb "być" is to the left of the adjective, not
more than 3 other words,
* the verb "będę" combined with the past participle (i.e. 3rd person
masculine imperfect form, e.g. "robił", pisał"), assuming
that "będę" is to the left of the adjective, not
more than 3 other words to the left of the participle OR directly
to the right of the participle ("robił będę").
The first-person masculine forms should be marked with curly brackets.
You should mark only the masculine form. Do not mark the form of "być"
(unless it clearly a masculine form, i.e. for "byłem").
The match should be case-insensitive.
The PoliMorf dictionary of inflected forms should be applied:
http://zil.ipipan.waw.pl/PoliMorf?action=AttachFile&do=get&target=PoliMorf-0.6.7.tab.gz
Suggested steps:
1. Extract all the needed forms from the PoliMorf dictionary:
* 1st person masculine past forms of verbs, unfortunately
this form is not directly present in the lexicon, you need
to add "em" to the 3rd person masculine form ("zrobił" => "zrobiłem")
* singular masculine nominative forms of adjectives
* masculine past participle (3rd person masculine imperfect forms of verbs)
You could do this using grep/cut commands — to obtain a simple text files
with a word in each line. You can do this once and commit the 3 files to your repository.
2. In your `run` script/program, read the 3 files and create a large
expression with alternatives. Use a regexp library based on DFAs (determintistic
finite-automatons).

25
TaskG01/simple.exp Normal file
View File

@ -0,0 +1,25 @@
Tu nic nie ma.
Wczoraj {ugotowałem} ziemniaki.
{Jechałem}, {jechałem} i {jechałem}, a potem się {zatrzymałem}.
{Umyłem} się mydłem.
Jestem {wysoki}.
Jest wysoki.
Mówią, że jestem od zawsze niezwykle {sprytny}.
aaaa {byłem} aaa {zielony} ddd
aaaa {byłem} aaa bbb {zielony} ddd
aaaa {byłem} aaa bbb ccc {zielony} ddd
aaaa {byłem} aaa bbb ccc ddd zielony ddd
aaaa był aaa bbb zielony ddd
aaaa byłam aaa bbb zielony ddd
aaaa byłam aaa bbb zielona ddd
teraz będę {pisał} książkę
będę teraz {pisał} książkę
będę teraz dla ciebie {pisał} książkę
teraz dla ciebie {pisał} będę księżkę
będę i on napisał książkę
aaa będę {śpiewał} bbb
aaa będę ccc {śpiewał} bbb
aaa będę ccc ddd {śpiewał} bbb
aaa będę ccc ddd eee {śpiewał} bbb
aaa będę ccc ddd eee fff śpiewał bbb
{pływałem} i {biegałem}

25
TaskG01/simple.in Normal file
View File

@ -0,0 +1,25 @@
Tu nic nie ma.
Wczoraj ugotowałem ziemniaki.
Jechałem, jechałem i jechałem, a potem się zatrzymałem.
Umyłem się mydłem.
Jestem wysoki.
Jest wysoki.
Mówią, że jestem od zawsze niezwykle sprytny.
aaaa byłem aaa zielony ddd
aaaa byłem aaa bbb zielony ddd
aaaa byłem aaa bbb ccc zielony ddd
aaaa byłem aaa bbb ccc ddd zielony ddd
aaaa był aaa bbb zielony ddd
aaaa byłam aaa bbb zielony ddd
aaaa byłam aaa bbb zielona ddd
teraz będę pisał książkę
będę teraz pisał książkę
będę teraz dla ciebie pisał książkę
teraz dla ciebie pisał będę księżkę
będę i on napisał książkę
aaa będę śpiewał bbb
aaa będę ccc śpiewał bbb
aaa będę ccc ddd śpiewał bbb
aaa będę ccc ddd eee śpiewał bbb
aaa będę ccc ddd eee fff śpiewał bbb
pływałem i biegałem

40
TaskG02/description.txt Normal file
View File

@ -0,0 +1,40 @@
Use regular expressions to mark Polish first-person feminine forms.
You should handle the following types of expressions:
* first-person feminine past forms of verbs ("zrobiłam", "pisałam", etc.),
* first-person singular feminine forms of the verb "być" ("be") combined
with singular feminine nominative forms of adjectives ("wysoka", "sprytna", etc.),
assuming that the form of the verb "być" is to the left of the adjective, not
more than 3 other words,
* the verb "będę" combined with the past participle (i.e. 3rd person
feminine imperfect form, e.g. "robiła", pisała"), assuming
that "będę" is to the left of the adjective, not
more than 3 other words to the left of the participle OR directly
to the right of the participle ("robiła będę").
The first-person feminine forms should be marked with curly brackets.
You should mark only the feminine form. Do not mark the form of "być"
(unless it clearly a feminine form, i.e. for "byłam").
The match should be case-insensitive.
The PoliMorf dictionary of inflected forms should be applied:
http://zil.ipipan.waw.pl/PoliMorf?action=AttachFile&do=get&target=PoliMorf-0.6.7.tab.gz
Suggested steps:
1. Extract all the needed forms from the PoliMorf dictionary:
* 1st person feminine past forms of verbs, unfortunately
this form is not directly present in the lexicon, you need
to add "m" to the 3rd person feminine form ("zrobiła" => "zrobiłam")
* singular feminine nominative forms of adjectives
* feminine past participle (3rd person feminine imperfect forms of verbs)
You could do this using grep/cut commands — to obtain a simple text files
with a word in each line. You can do this once and commit the 3 files to your repository.
2. In your `run` script/program, read the 3 files and create a large
expression with alternatives. Use a regexp library based on DFAs (determintistic
finite-automatons).

25
TaskG02/simple.exp Normal file
View File

@ -0,0 +1,25 @@
Tu nic nie ma.
Wczoraj {ugotowałam} ziemniaki.
{Jechałam}, {jechałam} i {jechałam}, a potem się {zatrzymałam}.
{Umyłam} się mydłem i bam, złam się.
Jestem {wysoka}.
Jest {wysoka}.
Mówią, że jestem od zawsze niezwykle {sprytna}.
aaaa {byłam} aaa {zielona} ddd
aaaa {byłam} aaa bbb {zielona} ddd
aaaa {byłam} aaa bbb ccc {zielona} ddd
aaaa {byłam} aaa bbb ccc ddd zielona ddd
aaaa była aaa bbb zielona ddd
aaaa byłem aaa bbb zielona ddd
aaaa byłem aaa bbb zielony ddd
teraz będę {pisała} książkę
będę teraz {pisała} książkę
będę teraz dla ciebie {pisała} książkę
teraz dla ciebie {pisała} będę księżkę
będę i ona napisała książkę
aaa będę {śpiewała} bbb
aaa będę ccc {śpiewała} bbb
aaa będę ccc ddd {śpiewała} bbb
aaa będę ccc ddd eee {śpiewała} bbb
aaa będę ccc ddd eee fff śpiewała bbb
{pływałam} i {biegałam}

25
TaskG02/simple.in Normal file
View File

@ -0,0 +1,25 @@
Tu nic nie ma.
Wczoraj ugotowałam ziemniaki.
Jechałam, jechałam i jechałam, a potem się zatrzymałam.
Umyłam się mydłem i bam, złam się.
Jestem wysoka.
Jest wysoka.
Mówią, że jestem od zawsze niezwykle sprytna.
aaaa byłam aaa zielona ddd
aaaa byłam aaa bbb zielona ddd
aaaa byłam aaa bbb ccc zielona ddd
aaaa byłam aaa bbb ccc ddd zielona ddd
aaaa była aaa bbb zielona ddd
aaaa byłem aaa bbb zielona ddd
aaaa byłem aaa bbb zielony ddd
teraz będę pisała książkę
będę teraz pisała książkę
będę teraz dla ciebie pisała książkę
teraz dla ciebie pisała będę księżkę
będę i ona napisała książkę
aaa będę śpiewała bbb
aaa będę ccc śpiewała bbb
aaa będę ccc ddd śpiewała bbb
aaa będę ccc ddd eee śpiewała bbb
aaa będę ccc ddd eee fff śpiewała bbb
pływałam i biegałam

20
TaskG03/description.txt Normal file
View File

@ -0,0 +1,20 @@
Use regular expressions to extract lines containing polish surnames. CASE INSENSITIVE
Download list of polish male and female surnames from here:
* https://dane.gov.pl/pl/dataset/1681,nazwiska-osob-zyjacych-wystepujace-w-rejestrze-pesel/resource/35279/table?page=1&per_page=20&q=&sort=
* https://dane.gov.pl/pl/dataset/1681,nazwiska-osob-zyjacych-wystepujace-w-rejestrze-pesel/resource/22817/table?page=1&per_page=20&q=&sort=
Extract lines from stdin containing any of the surnames.
Look only for surnames no matter casing (case insensitive).
The surname does not have to be surrounded by space or any other special characters.
Don't search for declined forms of surnames.
Check either NFA (e.g. re python library) and DFA (google re2) and compare them.
Submit solution based on a better method.
NOTE: You could extract the polish surnames list, save it to a file, then commit the file to your repository.
NOTE: You may set max_mem to a higher value than the default in re2 library.

File diff suppressed because one or more lines are too long

View File