diff --git a/TaskF02/run.py b/TaskF02/run.py new file mode 100644 index 0000000..f85f653 --- /dev/null +++ b/TaskF02/run.py @@ -0,0 +1,31 @@ +import re +import sys + +def analyze_line(line): + lowercase_count = len(re.findall(r'[a-ząćęłńóśźż]', line)) + uppercase_count = len(re.findall(r'[A-ZĄĆĘŁŃÓŚŹŻ]', line)) + digit_count = len(re.findall(r'\d', line)) + remaining_count = len(re.findall(r'[^a-ząćęłńóśźżA-ZĄĆĘŁŃÓŚŹŻ\d\n]', line)) + + result_line = f"{lowercase_count} {uppercase_count} {digit_count} {remaining_count}\n" + return result_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/TaskF02/simple.out b/TaskF02/simple.out new file mode 100644 index 0000000..bdba1e9 --- /dev/null +++ b/TaskF02/simple.out @@ -0,0 +1,3 @@ +7 2 0 2 +6 0 0 0 +6 1 1 2