1
0
forked from miczar1/djfz-24_25

D5 works for simple

This commit is contained in:
LuminoX 2025-01-29 00:38:33 +01:00
parent 639d5f9356
commit 077f7fa966

25
TaskD05/taskD5.py Normal file
View File

@ -0,0 +1,25 @@
import re
final = []
with open('simple.in', encoding='utf8') as file:
lines = file.readlines()
pattern = r"(\W*[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+\W+[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+\W)[\wąćęłńóśźżĄĆĘŁŃÓŚŹŻ]+"
for line in lines:
line = line.strip()
def replace_third_word(match):
prefix = match.group(1)
word_to_replace = match.group(0)[len(prefix):len(match.group(0))]
replacement = 'x' * len(word_to_replace)
return f"{prefix}{replacement}"
line = re.sub(pattern, replace_third_word, line)
print(line)
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
for number in line:
file.write(str(number) + ' ')
file.write('\n')