JFZ-1/TaskA04/task04.py

26 lines
906 B
Python
Raw Normal View History

2024-11-18 23:31:52 +01:00
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")