forked from miczar1/djfz-24_25
26 lines
906 B
Python
26 lines
906 B
Python
|
def find_max_digit_substrings(file_path):
|
||
|
try:
|
||
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||
|
for line in file:
|
||
|
max_digit_substrings = []
|
||
|
current_digits = ""
|
||
|
|
||
|
for char in line:
|
||
|
if char.isdigit():
|
||
|
current_digits += char
|
||
|
else:
|
||
|
if current_digits:
|
||
|
max_digit_substrings.append(current_digits)
|
||
|
current_digits = ""
|
||
|
|
||
|
if current_digits:
|
||
|
max_digit_substrings.append(current_digits)
|
||
|
|
||
|
if max_digit_substrings:
|
||
|
print(" ".join(max_digit_substrings))
|
||
|
except Exception as e:
|
||
|
print(f"An error occurred: {e}")
|
||
|
|
||
|
find_max_digit_substrings("TaskA04\simple.in")
|
||
|
find_max_digit_substrings("TaskA04\polish_wiki_excerpt.in")
|