djfz-2023-s464986/TaskD04/run.py

21 lines
506 B
Python
Raw Normal View History

2023-11-25 16:08:43 +01:00
import re
import sys
def remove_non_digits(line):
return re.sub(r'[^0-9\s]', '', line)
processed_lines = []
for line in sys.stdin:
processed_line = remove_non_digits(line)
processed_line = re.sub(r'^\s+|\s+$', '', processed_line)
processed_line = re.sub(r'\s+', ' ', processed_line)
digit_groups = re.findall(r'\d+', processed_line)
if digit_groups:
processed_lines.append(' '.join(digit_groups))
print('\n'.join(processed_lines), end='')