D5 changes, checker added

This commit is contained in:
LuminoX 2025-01-29 02:01:11 +01:00
parent 077f7fa966
commit 8c0af38006
3 changed files with 20 additions and 4 deletions

View File

@ -23,6 +23,6 @@ with open('polish_wiki_excerpt.in', encoding='utf8') as file:
print(line)
final.append(line)
# with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
# for line in final:
# file.write(line + '\n')
with open('polish_wiki_excerpt.out', 'w', encoding='utf8') as file:
for line in final:
file.write(line + '\n')

View File

@ -13,7 +13,7 @@ with open('simple.in', encoding='utf8') as file:
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}"
return prefix + replacement
line = re.sub(pattern, replace_third_word, line)
print(line)

16
checker.py Normal file
View File

@ -0,0 +1,16 @@
with open("./TaskD01/polish_wiki_excerpt.out", 'r', encoding='utf8') as f:
lines1 = f.readlines()
with open("./TaskD01/polish_wiki_excerpt.exp", 'r', encoding='utf8') as f:
lines2 = f.readlines()
i = 1
for line1, line2 in zip(lines1, lines2):
if line1.strip() == line2.strip():
pass
# print('hurray')
else:
print(f'{i}: bad')
i += 1