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