TaskF00
This commit is contained in:
parent
51601587c8
commit
528bee3224
31
TaskF00/run.py
Normal file
31
TaskF00/run.py
Normal 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
3
TaskF00/simple.out
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dece 34 dfd gfdfedc
|
||||||
|
f33sdfsdbcdebcdedsfsdf
|
||||||
|
3r
|
Loading…
Reference in New Issue
Block a user