This commit is contained in:
Pawel Felcyn 2024-01-21 21:43:56 +01:00
parent 9081d592a0
commit da203c4b6f
5 changed files with 92 additions and 0 deletions

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

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

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

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