This commit is contained in:
IgnBys 2024-01-08 13:06:56 +01:00
parent 528bee3224
commit e80ed8ce6c
3 changed files with 36 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import re
import sys
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'}
@ -24,8 +25,8 @@ def main_function(input_file, output_file):
for row in file:
write_answer(replace_digits_with_letters(row), output_file)
output_file ='simple.out'
input_file = 'simple.in'
# output_file ='simple.out'
# input_file = 'simple.in'
input_file = sys.argv[1]
output_file = sys.argv[2]
main_function(input_file, output_file)
# input_file = sys.argv[1]
# output_file = sys.argv[2]

28
TaskF01/run.py Normal file
View File

@ -0,0 +1,28 @@
import re
import sys
def transform_line(line):
def transform_word(match):
word = match.group()
return ''.join(char.lower() if char.isupper() else char.upper() for char in word)
pattern = re.compile(r'\b\w*[a-ząćęłńóśźż]+[A-ZĄĆĘŁŃÓŚŹŻ]\w*\b|\b\w*[A-ZĄĆĘŁŃÓŚŹŻ]+[a-ząćęłńóśźż]\w*\b')
transformed_line = pattern.sub(transform_word, line)
return transformed_line
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(transform_line(row), output_file)
# output_file ='simple.out'
# input_file = 'simple.in'
input_file = sys.argv[1]
output_file = sys.argv[2]
main_function(input_file, output_file)

3
TaskF01/simple.out Normal file
View File

@ -0,0 +1,3 @@
ala mA KOTa
lallaa
żUK