From 448e1da24f06433b0d8aa774d8a2d704eb2e0bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A8=D0=B8=D0=BC=D1=87=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 2 Jul 2025 13:12:33 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comparsion.py | 10 ++++++++++ last_friday_datetime.py | 14 ++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 comparsion.py create mode 100644 last_friday_datetime.py diff --git a/comparsion.py b/comparsion.py new file mode 100644 index 0000000..c36aa4f --- /dev/null +++ b/comparsion.py @@ -0,0 +1,10 @@ +def compare(a: str) -> bool: + for i in range(len(a)): + if(a[i].isdigit() == False): + if a[i] == "<": + return int(a[:i]) < int(a[i + 1:]) + else: + return int(a[:i]) > int(a[i + 1:]) + +print(compare("2>5")) + \ No newline at end of file diff --git a/last_friday_datetime.py b/last_friday_datetime.py new file mode 100644 index 0000000..d4582e7 --- /dev/null +++ b/last_friday_datetime.py @@ -0,0 +1,14 @@ +from datetime import datetime, timedelta + +def get_last_friday(a: str) -> str: + date = datetime.strptime(a, "%m/%Y").date() + next_month = date.replace(day=28) + timedelta(days=7) + last_day = next_month - timedelta(days=next_month.day) + + # Идем назад до пятницы + while last_day.weekday() != 4: + last_day -= timedelta(days=1) + + return last_day.strftime("%d.%m.%Y") + +print(get_last_friday("05/2022")) \ No newline at end of file