def check(collection):
return len(set(collection)) == len(collection)
check(([1], [1]))
from collections import Hashable, defaultdict
def check(t: tuple):
try:
return len(set(t)) == len(t)
except TypeError:
tt = ([], [])
for e in t:
tt[isinstance(e, Hashable)].append(e)
if not check(tt[1]):
return False
d = defaultdict(list)
for e in tt[0]:
d[type(e)].append(e)
for l in d.values():
l.sort()
if any(a == b for a, b in zip(l, l[1:])):
return False
return True
print(check(([1], [1])))
print(check(([1], None)))
print(check(([1], {1})))
def check(t: tuple):
return len(set(t)) == len(t)
class A:
def __hash__(self):
return 0
def __eq__(self, other):
return id(self) != id(other)
a, b = A(), A()
print(check((a, a)), a != a)
print(check((a, b)), a != b)
print(check((a, 1)), a != 1)
arr = list(arr) # ха-ха
arr = arr[:] # слайс быстрее конструктора, это знают все, кроме тебя
В реальном опыте на сколько следует делать ширину и высоту стены больше ее толщины?Нинасколько. Я полагаю (ты очень экономный собеседник, но уж я обойдусь без распросов), что речь идёт о реальных покупных утеплителях мипа мин.ваты, и нарезать из них ломтики - дело неблагодарное. Какая будет толщина - такая и будет.
def push(l, a):
return (l, a)
def pop(l):
tail, a = l
return tail, a
def getbyidx(l, i):
tail, a = pop(l)
return getbyidx(tail, i - 1) if i else a
def setbyidx(l, i, b):
tail, a = pop(l)
return (setbyidx(tail, i - 1), a) if i else (tail, b)