From ed4c60e3ec8de8a1892715ddd2111123de16c119 Mon Sep 17 00:00:00 2001 From: Polevara Veronika Date: Sat, 25 Nov 2023 15:59:13 +0100 Subject: [PATCH] Dodanie D-Task --- TaskD01/description.txt | 5 +++++ TaskD01/run.py | 13 +++++++++++++ TaskD01/simple.exp | 2 ++ TaskD01/simple.in | 3 +++ TaskD01/simple.out | 2 ++ TaskD02/description.txt | 7 +++++++ TaskD02/run.py | 13 +++++++++++++ TaskD02/simple.exp | 3 +++ TaskD02/simple.in | 5 +++++ TaskD02/simple.out | 3 +++ TaskD03/description.txt | 6 ++++++ TaskD03/run.py | 14 ++++++++++++++ TaskD03/simple.exp | 3 +++ TaskD03/simple.in | 5 +++++ TaskD03/simple.out | 3 +++ TaskD04/description.txt | 6 ++++++ TaskD04/run.py | 21 +++++++++++++++++++++ TaskD04/simple.exp | 4 ++++ TaskD04/simple.in | 5 +++++ TaskD04/simple.out | 4 ++++ 20 files changed, 127 insertions(+) create mode 100644 TaskD01/description.txt create mode 100644 TaskD01/run.py create mode 100644 TaskD01/simple.exp create mode 100644 TaskD01/simple.in create mode 100644 TaskD01/simple.out create mode 100644 TaskD02/description.txt create mode 100644 TaskD02/run.py create mode 100644 TaskD02/simple.exp create mode 100644 TaskD02/simple.in create mode 100644 TaskD02/simple.out create mode 100644 TaskD03/description.txt create mode 100644 TaskD03/run.py create mode 100644 TaskD03/simple.exp create mode 100644 TaskD03/simple.in create mode 100644 TaskD03/simple.out create mode 100644 TaskD04/description.txt create mode 100644 TaskD04/run.py create mode 100644 TaskD04/simple.exp create mode 100644 TaskD04/simple.in create mode 100644 TaskD04/simple.out diff --git a/TaskD01/description.txt b/TaskD01/description.txt new file mode 100644 index 0000000..f2365af --- /dev/null +++ b/TaskD01/description.txt @@ -0,0 +1,5 @@ +Write a program to find lines containing the word "Hamlet". +Do use regular expressions. + +POINTS: 1 +DEADLINE: 2023-11-26 23:59:59 \ No newline at end of file diff --git a/TaskD01/run.py b/TaskD01/run.py new file mode 100644 index 0000000..bdcf3a7 --- /dev/null +++ b/TaskD01/run.py @@ -0,0 +1,13 @@ +import re +import sys + +found_lines = [] + + +for line in sys.stdin: + if re.search(r'\bHamlet\b', line): + found_lines.append(line.strip()) + + +if found_lines: + print('\n'.join(found_lines), end='') \ No newline at end of file diff --git a/TaskD01/simple.exp b/TaskD01/simple.exp new file mode 100644 index 0000000..0064e87 --- /dev/null +++ b/TaskD01/simple.exp @@ -0,0 +1,2 @@ +Here comes Hamlet +Hamlet Hamlet again \ No newline at end of file diff --git a/TaskD01/simple.in b/TaskD01/simple.in new file mode 100644 index 0000000..24e23e3 --- /dev/null +++ b/TaskD01/simple.in @@ -0,0 +1,3 @@ +Here comes Hamlet +ABC +Hamlet Hamlet again \ No newline at end of file diff --git a/TaskD01/simple.out b/TaskD01/simple.out new file mode 100644 index 0000000..0064e87 --- /dev/null +++ b/TaskD01/simple.out @@ -0,0 +1,2 @@ +Here comes Hamlet +Hamlet Hamlet again \ No newline at end of file diff --git a/TaskD02/description.txt b/TaskD02/description.txt new file mode 100644 index 0000000..d10a828 --- /dev/null +++ b/TaskD02/description.txt @@ -0,0 +1,7 @@ +Write a program to find lines containing the word "pies" separated by spaces. +The word does not need to have space on the left if it is the line beginning or space on the right if it is line ending. +Return line no matter of word "pies" casing. +Do use regular expressions. + +POINTS: 1 +DEADLINE: 2023-11-26 23:59:59 \ No newline at end of file diff --git a/TaskD02/run.py b/TaskD02/run.py new file mode 100644 index 0000000..8128990 --- /dev/null +++ b/TaskD02/run.py @@ -0,0 +1,13 @@ +import re +import sys + +found_lines = [] + +for line in sys.stdin: + if re.search(r'\b\s*pies\s*\b', line, flags=re.IGNORECASE): + found_lines.append(line.strip()) + + +if found_lines: + print('\n'.join(found_lines), end='') + diff --git a/TaskD02/simple.exp b/TaskD02/simple.exp new file mode 100644 index 0000000..caa7f93 --- /dev/null +++ b/TaskD02/simple.exp @@ -0,0 +1,3 @@ +Pies ma Ale +Kot i pies to zwierzeta +pies \ No newline at end of file diff --git a/TaskD02/simple.in b/TaskD02/simple.in new file mode 100644 index 0000000..cbf2ba9 --- /dev/null +++ b/TaskD02/simple.in @@ -0,0 +1,5 @@ +Pies ma Ale +Ala ma psa +tu nic nie ma +Kot i pies to zwierzeta +pies \ No newline at end of file diff --git a/TaskD02/simple.out b/TaskD02/simple.out new file mode 100644 index 0000000..caa7f93 --- /dev/null +++ b/TaskD02/simple.out @@ -0,0 +1,3 @@ +Pies ma Ale +Kot i pies to zwierzeta +pies \ No newline at end of file diff --git a/TaskD03/description.txt b/TaskD03/description.txt new file mode 100644 index 0000000..114f376 --- /dev/null +++ b/TaskD03/description.txt @@ -0,0 +1,6 @@ +Write a program to find lines containing date from 1900 to 1999 in format '19XX r.' no matter what on the left or right of the expression. +Note that part ' r.' is obligatory. +Do use regular expressions. + +POINTS: 1 +DEADLINE: 2023-11-26 23:59:59 \ No newline at end of file diff --git a/TaskD03/run.py b/TaskD03/run.py new file mode 100644 index 0000000..05f6da4 --- /dev/null +++ b/TaskD03/run.py @@ -0,0 +1,14 @@ +import re +import sys + + +found_lines = [] + +for line in sys.stdin: + if re.search(r'\b19\d{2}\s*r\.\b|\b\W19\d{2}\s*r\.\b|\b19\d{2}\s*r\.\W', line, flags=re.IGNORECASE): + found_lines.append(line.strip()) + + +if found_lines: + print('\n'.join(found_lines), end='') + diff --git a/TaskD03/simple.exp b/TaskD03/simple.exp new file mode 100644 index 0000000..175c58f --- /dev/null +++ b/TaskD03/simple.exp @@ -0,0 +1,3 @@ +Kiedys byl 1934 r. +Kiedys byl 1934 r.fsdfsdfsdf +1934 r. to jakas data \ No newline at end of file diff --git a/TaskD03/simple.in b/TaskD03/simple.in new file mode 100644 index 0000000..e3a93b7 --- /dev/null +++ b/TaskD03/simple.in @@ -0,0 +1,5 @@ +Kiedys byl 1934 r. +Kiedys byl 1934 r.fsdfsdfsdf +Kiedys byl 1935 rok +1934 r. to jakas data +1934 to tez jakas data \ No newline at end of file diff --git a/TaskD03/simple.out b/TaskD03/simple.out new file mode 100644 index 0000000..175c58f --- /dev/null +++ b/TaskD03/simple.out @@ -0,0 +1,3 @@ +Kiedys byl 1934 r. +Kiedys byl 1934 r.fsdfsdfsdf +1934 r. to jakas data \ No newline at end of file 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