TaskF03
This commit is contained in:
parent
80be8e6e8b
commit
3f957f6706
@ -22,10 +22,10 @@ def main_function(input_file, output_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]
|
||||
# output_file ='simple.out'
|
||||
# input_file = 'simple.in'
|
||||
input_file = sys.argv[1]
|
||||
output_file = sys.argv[2]
|
||||
main_function(input_file, output_file)
|
||||
|
||||
|
||||
|
29
TaskF03/run.py
Normal file
29
TaskF03/run.py
Normal file
@ -0,0 +1,29 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
def analyze_line(line):
|
||||
lowercase_count = len(re.findall(r'\b[a-ząćęłńóśźż]\w*\b', line))
|
||||
uppercase_count = len(re.findall(r'\b[A-ZĄĆĘŁŃÓŚŹŻ]\w*\b', line))
|
||||
|
||||
result_line = f"{lowercase_count} {uppercase_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)
|
||||
|
||||
|
2
TaskF03/simple.out
Normal file
2
TaskF03/simple.out
Normal file
@ -0,0 +1,2 @@
|
||||
2 1
|
||||
1 0
|
29
TaskF04/run.py
Normal file
29
TaskF04/run.py
Normal file
@ -0,0 +1,29 @@
|
||||
import re
|
||||
import sys
|
||||
|
||||
def analyze_line(line):
|
||||
lowercase_count = len(re.findall(r'\b[a-ząćęłńóśźż]\w*\b', line))
|
||||
uppercase_count = len(re.findall(r'\b[A-ZĄĆĘŁŃÓŚŹŻ]\w*\b', line))
|
||||
|
||||
result_line = f"{lowercase_count} {uppercase_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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user