jfz-2023-s473564/TaskF00/run.py
2024-01-19 15:20:29 +01:00

26 lines
687 B
Python

import re
def substitute_digits(input_string):
def replace_digit(match):
digits = match.group()
replaced_digits = ''
for digit in digits:
if '0' <= digit <= '9':
replaced_digits += chr(ord('a') + int(digit))
else:
replaced_digits += digit
return replaced_digits
pattern = re.compile(r'\d{4}')
substituted_string = pattern.sub(replace_digit, input_string)
return substituted_string
file_path = 'simple.in'
with open(file_path, 'r', encoding = 'utf-8') as file:
for line in file:
line = line.rstrip('\n')
result = substitute_digits(line)
print(result)