This commit is contained in:
IgnBys 2024-01-08 12:43:44 +01:00
parent 51601587c8
commit 528bee3224
2 changed files with 34 additions and 0 deletions

31
TaskF00/run.py Normal file
View File

@ -0,0 +1,31 @@
import re
def replace_digits_with_letters(input_string):
digit_to_letter = {'0': 'a', '1': 'b', '2': 'c', '3': 'd', '4': 'e', '5': 'f', '6': 'g', '7': 'h', '8': 'i', '9': 'j'}
def replace(match):
number = match.group()
replaced_number = ''.join(digit_to_letter[digit] for digit in number)
return replaced_number
pattern = re.compile(r'\b\d{4}\b|\d{4}')
result = pattern.sub(replace, input_string)
return result
def write_answer(row, ouput_file):
with open(ouput_file, "a", encoding="utf-8") as file:
file.write(row)
def main_function(input_file, output_file):
with open(output_file, "w", encoding="utf-8") as output_file1:
with open(input_file, "r", encoding="utf-8") as file:
for row in file:
write_answer(replace_digits_with_letters(row), output_file)
output_file ='simple.out'
input_file = 'simple.in'
main_function(input_file, output_file)
# input_file = sys.argv[1]
# output_file = sys.argv[2]

3
TaskF00/simple.out Normal file
View File

@ -0,0 +1,3 @@
dece 34 dfd gfdfedc
f33sdfsdbcdebcdedsfsdf
3r