From 7e065b45b7cf20a1fc712723ec31119e8c9f9ac6 Mon Sep 17 00:00:00 2001 From: LeterZP Date: Fri, 13 Feb 2026 19:41:40 +0300 Subject: [PATCH] pass --- Informatics_Lab3_Task1.py | 37 ++++++++++++++++++++++++++++++++++++ Informatics_Lab3_Task2.py | 34 +++++++++++++++++++++++++++++++++ Informatics_Lab3_Task3.py | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 Informatics_Lab3_Task1.py create mode 100644 Informatics_Lab3_Task2.py create mode 100644 Informatics_Lab3_Task3.py diff --git a/Informatics_Lab3_Task1.py b/Informatics_Lab3_Task1.py new file mode 100644 index 0000000..f61b2d6 --- /dev/null +++ b/Informatics_Lab3_Task1.py @@ -0,0 +1,37 @@ +# Author = Bosenko Boris Igorevich +# Group = P3115 +# Date = 12.11.2025 + +import re + +def haiku(text): + sl = '[аеёиоуыэюя]' + if not(re.fullmatch(r'[^/]*/[^/]*/[^/]*', text)): + return "Не хайку. Должно быть 3 строки." + elif re.match(sl+"{5}/"+sl+"{7}/"+sl+"{5}", "".join(re.findall('[аеёиоуыэюя/]', str.lower(text)))): + return "Хайку!" + else: + return "Не хайку." + +if __name__ == "__main__": + try: + tests = [ + "Ветер за окном. / Дождь слегка бьёт по окнам. / Сегодня пишу псж.", + " Один день назадю / Был сильный дождь. / Много луж на улице.", + "Еще один день. / Очень скучно.", + "Один, четыре. / Два, три, пять, шесть, семь, восемь. / Девять, десять, ноль. ", + "Четыре. / Двенадцать. / Восемь. / Пятнадцать. / Тринадцать." + ] + for test in tests: + print(haiku(test), end=" ") + print() + results = [ + "Хайку!", + "Не хайку.", + "Не хайку. Должно быть 3 строки.", + "Хайку!", + "Не хайку. Должно быть 3 строки." + ] + print(*results, sep=" ") + except Exception as error: + print(f"Ошибка: {error}") \ No newline at end of file diff --git a/Informatics_Lab3_Task2.py b/Informatics_Lab3_Task2.py new file mode 100644 index 0000000..5430923 --- /dev/null +++ b/Informatics_Lab3_Task2.py @@ -0,0 +1,34 @@ +# Author = Bosenko Boris Igorevich +# Group = P3115 +# Date = 12.11.2025 + +import re + +def mail(email): + if re.fullmatch(r'[\w.]*@[a-zA-Zа-яА-я]+(\.[a-zA-Zа-яА-я]+)+', email): + return email[email.index("@") + 1:] + else: + return "Fail!" + +if __name__ == "__main__": + try: + tests = [ + "day@dfgdfg..", + "ind_out.us@out_because.us", + "2let@it.be.me", + "no_here.there@and.there", + "1322list@another8916.21" + ] + for test in tests: + print(mail(test), end=" ") + print() + results = [ + "not.here", + "Fail!", + "it.be.me", + "and.there", + "Fail!" + ] + print(*results, sep=" ") + except Exception as error: + print(f"Ошибка: {error}") diff --git a/Informatics_Lab3_Task3.py b/Informatics_Lab3_Task3.py new file mode 100644 index 0000000..8d76e15 --- /dev/null +++ b/Informatics_Lab3_Task3.py @@ -0,0 +1,40 @@ +# Author = Bosenko Boris Igorevich +# Group = P3115 +# Date = 12.11.2025 + +import re + +def cron(text): + pat_min = r'([*]*|((([1-5]?[0-9])[,])*|(((([1-5]?[0-9])|[*])[/])|(([1 5]?[0-9])[-]))?)([1-5]?[0-9])) ' + pat_hour = r'([*]*|(((1?[0-9]|2[0-3])[,])*|(((((1?[0-9]|2[0-3])|[*])[/])|((1?[0-9]|2[0-3])[-]))?)(1?[0-9]|2[0-3]))) ' + pat_day = r'([*]*|(((([1-9]|[1-2][0-9]|3[0-1])[,])*|(((([1-9]|[1-2][0-9]|3[0-1])|[*])[/])|(([1-9]|[1-2][0-9]|3[0-1])[-]))?)([1-9]|[1-2][0-9]|3[0-1]))) ' + pat_mon = r'([*]*|(((([1-9]|(1[0-2]))[,])*|(((([1-9]|(1[0-2]))|[*])[/])|(([1-9]|(1[0-2]))[-]))?)([1-9]|(1[0-2])))) ' + pat_week = r'([*]*|(((([0-6])[,])*|(((([0-6])|[*])[/])|(([0-6])[-]))?)[0-6]))' + pat = r'\s*' + pat_min + pat_hour + pat_day + pat_mon + pat_week + r'\s*' + if re.fullmatch(pat, text): + return "Cron-выражение правильное!" + else: + return "Cron-выражение содержит ошибку!" + +if __name__ == "__main__": + try: + tests = [ + "* 88888 21 * 4", + " 5-15 * 4 6-8 * ", + "** /4 11 * -6 ", + "18,21 * 4/6 * 1,3", + " * 4 19 21 " + ] + for test in tests: + print(cron(test), end=" ") + print() + results = [ + "Cron-выражение правильное!", + "Cron-выражение правильное!", + "Cron-выражение содержит ошибку!", + "Cron-выражение правильное!", + "Cron-выражение содержит ошибку!" + ] + print(*results, sep=" ") + except Exception as error: + print(f"Ошибка: {error}") \ No newline at end of file