Skip to content

Instantly share code, notes, and snippets.

View IgorZyktin's full-sized avatar

Игорь IgorZyktin

  • Encost
  • Moscow
View GitHub Profile
odd = [
0,
1,
3,
5,
7,
9,
]
even = [
@IgorZyktin
IgorZyktin / menus.py
Created January 15, 2023 20:29
Menus
create table test_menu
(
id serial PRIMARY KEY,
name VARCHAR(50) UNIQUE NOT NULL
);
insert into test_menu (name)
values ('Барское меню'),
('Купеческое меню'),
('Холопское меню');
@IgorZyktin
IgorZyktin / returns.py
Created August 25, 2022 08:51
Type safe returns
import random
from typing import Generic
from typing import TypeVar
from typing_extensions import reveal_type
V = TypeVar('V', covariant=True)
E = TypeVar('E', covariant=True)
"""Поиск оптимальной цепочки городов.
Пример входных данных:
ABCD
Сегменты:
1. AB
2. BC
3. BCD
4. DE
from pprint import pprint
from random import randint
class Room:
def __init__(self, a, b):
self.a = a
self.b = b
def s(self):
from abc import ABC, abstractmethod
class A(ABC):
@property
@abstractmethod
def attr(self) -> str:
...
import random
import statistics
import string
import time
import uuid
VARIANTS = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
ks = []
ds = []
import random
my_set = set(range(100))
my_list = list(range(100))
N = 10
ATTEMPTS = 5
print('\nVariant 1: using generator')
for _ in range(ATTEMPTS):
from collections import UserString
from typing import Union
class StrIns(UserString):
def __setitem__(self, key: Union[int, slice], value: str) -> None:
if isinstance(key, int):
self._assign_one_element(key, value)
elif isinstance(key, slice):
import random
from typing import List
from typing import MutableSequence
from typing import Optional
from typing import TypeVar
T = TypeVar('T')
Sparse = MutableSequence[Optional[T]]
MIN = 0.0