diff --git a/TaskD04/description.txt b/TaskD04/description.txt new file mode 100644 index 0000000..4db2554 --- /dev/null +++ b/TaskD04/description.txt @@ -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 \ No newline at end of file diff --git a/TaskD04/run.py b/TaskD04/run.py new file mode 100644 index 0000000..fc5985a --- /dev/null +++ b/TaskD04/run.py @@ -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='') \ No newline at end of file diff --git a/TaskD04/simple.exp b/TaskD04/simple.exp new file mode 100644 index 0000000..c184ec8 --- /dev/null +++ b/TaskD04/simple.exp @@ -0,0 +1,4 @@ +34234 34 5 +34535 +34 +1992 1999 \ No newline at end of file diff --git a/TaskD04/simple.in b/TaskD04/simple.in new file mode 100644 index 0000000..df710ac --- /dev/null +++ b/TaskD04/simple.in @@ -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 \ No newline at end of file diff --git a/TaskD04/simple.out b/TaskD04/simple.out new file mode 100644 index 0000000..c184ec8 --- /dev/null +++ b/TaskD04/simple.out @@ -0,0 +1,4 @@ +34234 34 5 +34535 +34 +1992 1999 \ No newline at end of file