From 528bee322420783ff26c49533eee933b758f694c Mon Sep 17 00:00:00 2001 From: IgnBys Date: Mon, 8 Jan 2024 12:43:44 +0100 Subject: [PATCH] TaskF00 --- TaskF00/run.py | 31 +++++++++++++++++++++++++++++++ TaskF00/simple.out | 3 +++ 2 files changed, 34 insertions(+) create mode 100644 TaskF00/run.py create mode 100644 TaskF00/simple.out diff --git a/TaskF00/run.py b/TaskF00/run.py new file mode 100644 index 0000000..853b135 --- /dev/null +++ b/TaskF00/run.py @@ -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] diff --git a/TaskF00/simple.out b/TaskF00/simple.out new file mode 100644 index 0000000..bf27951 --- /dev/null +++ b/TaskF00/simple.out @@ -0,0 +1,3 @@ +dece 34 dfd gfdfedc +f33sdfsdbcdebcdedsfsdf +3r