2024-01-08 14:38:30 +01:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
2024-01-20 17:32:06 +01:00
|
|
|
def replace_second_number(line):
|
|
|
|
pattern = re.compile(r'(\D*\d+\D*).*?(\d+)(.*)')
|
|
|
|
group1, group2, group3 = '', '', ''
|
|
|
|
matches = pattern.search(line)
|
|
|
|
if matches:
|
|
|
|
group1 = matches.group(1)
|
|
|
|
group2 = matches.group(2)
|
|
|
|
group3 = matches.group(3)
|
|
|
|
if group2 != '':
|
|
|
|
modified_line = group1 + group3
|
|
|
|
return modified_line
|
|
|
|
else:
|
|
|
|
return line
|
2024-01-08 14:38:30 +01:00
|
|
|
|
|
|
|
def write_answer(row, ouput_file):
|
|
|
|
with open(ouput_file, "a", encoding="utf-8") as file:
|
2024-01-20 17:32:06 +01:00
|
|
|
file.write(row+'\n')
|
2024-01-08 14:38:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
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:
|
2024-01-20 17:32:06 +01:00
|
|
|
write_answer(replace_second_number(row), output_file)
|
2024-01-08 14:38:30 +01:00
|
|
|
|
2024-01-20 17:32:06 +01:00
|
|
|
# output_file ='simple.out'
|
|
|
|
# input_file = 'simple.in'
|
|
|
|
input_file = sys.argv[1]
|
|
|
|
output_file = sys.argv[2]
|
2024-01-08 14:38:30 +01:00
|
|
|
main_function(input_file, output_file)
|
|
|
|
|
|
|
|
|