Upload files to "TaskA04"
This commit is contained in:
parent
0c6baf6172
commit
1c636fa8e8
29
TaskA04/run.py
Normal file
29
TaskA04/run.py
Normal file
@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
def TaskA04(filename):
|
||||
print("_______")
|
||||
with open(filename, 'r', encoding='utf-8') as file:
|
||||
for line_number, line in enumerate(file, start=1):
|
||||
substrings = []
|
||||
current_substring = ''
|
||||
|
||||
for char in line:
|
||||
if char.isdigit():
|
||||
current_substring += char
|
||||
else:
|
||||
if current_substring:
|
||||
substrings.append(current_substring)
|
||||
current_substring = ''
|
||||
|
||||
if current_substring:
|
||||
substrings.append(current_substring)
|
||||
|
||||
if substrings:
|
||||
max_length = max(len(substring) for substring in substrings)
|
||||
|
||||
if max_length > 0:
|
||||
print(f"Line {line_number}: {' '.join(substring for substring in substrings if len(substring) == max_length)}")
|
||||
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
file_path = os.path.join(script_dir, 'simple.in')
|
||||
TaskA04(file_path)
|
Loading…
Reference in New Issue
Block a user