From 2d8a843df23732240982554f8e769e2c4c219f22 Mon Sep 17 00:00:00 2001 From: Veronika Polevara Date: Sat, 25 Nov 2023 16:07:14 +0100 Subject: [PATCH] Upload files to 'TaskD01' --- TaskD01/description.txt | 5 +++++ TaskD01/run.py | 13 +++++++++++++ TaskD01/simple.exp | 2 ++ TaskD01/simple.in | 3 +++ TaskD01/simple.out | 2 ++ 5 files changed, 25 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 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