wykonane zadania z tasku D
This commit is contained in:
parent
92b31192b3
commit
f424d4529c
|
@ -0,0 +1,6 @@
|
|||
Write a program to find all maximum substrings of digits.
|
||||
Return only these substrings separated by spaces in their order.
|
||||
Do use regular expressions.
|
||||
|
||||
POINTS: 2
|
||||
DEADLINE: 2023-11-26 23:59:59
|
|
@ -0,0 +1,21 @@
|
|||
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='')
|
|
@ -0,0 +1,4 @@
|
|||
34234 34 5
|
||||
34535
|
||||
34
|
||||
1992 1999
|
|
@ -0,0 +1,5 @@
|
|||
34234 34 dfd gfd 5
|
||||
34535
|
||||
fsdflskfjsdflk
|
||||
fsdkfj sdf34fdfd
|
||||
The company was established in 1992 from the merger of Authorware, Inc. (creators of the Authorware package) and MacroMind-Paracomp (producer of Macromind Director). In 1999, Macromedia purchased Allaire and its bi
|
|
@ -0,0 +1,4 @@
|
|||
34234 34 5
|
||||
34535
|
||||
34
|
||||
1992 1999
|
Loading…
Reference in New Issue