diff --git a/TaskF04/run.py b/TaskF04/run.py index 8766b89..0defbf9 100644 --- a/TaskF04/run.py +++ b/TaskF04/run.py @@ -9,9 +9,6 @@ def replace_second_number(line): group1 = matches.group(1) group2 = matches.group(2) group3 = matches.group(3) - print('group1:', group1) - print('group2:', group2) - print('group3:', group3) if group2 != '': modified_line = group1 + group3 return modified_line diff --git a/TaskF04/simple.out b/TaskF04/simple.out index d42a47f..489e39e 100644 --- a/TaskF04/simple.out +++ b/TaskF04/simple.out @@ -1,3 +1,3 @@ Mam 2 jabłka i banananów. -Mam 22 jabłka i banananów oraz 20 gruszek. -Widziałem 2 bociany. +Mam 2 jabłka i 35 banananów oraz 20 gruszek. +Widzia2łem bociany. diff --git a/TaskF05/run.py b/TaskF05/run.py new file mode 100644 index 0000000..8a3cd8d --- /dev/null +++ b/TaskF05/run.py @@ -0,0 +1,32 @@ +import re +import sys + + +def analyze_line(line): + word_pattern = r'\w+' + pattern = re.compile(r'(\w+ \w+ )(\w+)(.*)') + words = re.findall(word_pattern, line) + if len(words) >= 3: + modified_line = re.sub(pattern, r'\1' + 'x' * len(words[2]) + r'\3', line, count=1) + return modified_line + else: + return 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(analyze_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) + + diff --git a/TaskF05/simple.out b/TaskF05/simple.out new file mode 100644 index 0000000..daf42d5 --- /dev/null +++ b/TaskF05/simple.out @@ -0,0 +1,2 @@ +Mam 2 xxxxxx i 35 banananów. +Widziałem 2 xxxxxxx.