Предизвикателства > Abomination decorator > Решения > Решението на Костадин Русалов

Резултати
2 точки от тестове
0 точки от учител

2 точки общо

3 успешни теста
1 неуспешни теста
Код

1type_check = (d := __import__('codecs').decode,  := lambda s: str(d(s, 'hex'), 'utf-8'), lambda : (lambda *ξ: lambda λ: lambda *_, **__: (print((b'496e76616c696420696e70757420617267756d656e74732c20657870656374656420257321') % ', '.join(str(σ) for σ in ξ)) if not all(type(x) in ξ for x in _ + tuple(__.values())) else '馬鹿', λ(*_, **__))[1], lambda *ξ: lambda λ: lambda *_, **__: (print((b'496e76616c6964206f75747075742076616c75652c20657870656374656420257321') % ', '.join(str(σ) for σ in ξ)) if type(λ(*_, **__)) not in ξ else '馬鹿', λ(*_, **__))[1])[{'in': 0, 'out': 1}.get(, 'възбудѝ грешка!')])[2]

F...
======================================================================
FAIL: test_check_both (test.TestTypeCheck.test_check_both)
The decorator should report invalid "in" and "out" together.
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python3.12/unittest/mock.py", line 1390, in patched
return func(*newargs, **newkeywargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/test.py", line 101, in test_check_both
self.assertEqual(mock_print.call_count, 2)
AssertionError: 3 != 2

----------------------------------------------------------------------
Ran 4 tests in 0.003s

FAILED (failures=1)

Дискусия
Костадин Русалов
24.10.2024 21:26

fixed. r оправя всичко. ```python type_check = (d := __import__('codecs').decode, 譯 := lambda s: str(d(s, 'hex'), 'utf-8'), lambda 型: (lambda *ξ: lambda λ: lambda *_, **__: (print(譯(b'496e76616c696420696e70757420617267756d656e74732c20657870656374656420257321') % ', '.join(str(σ) for σ in ξ)) if not all(type(x) in ξ for x in _ + tuple(__.values())) else '馬鹿', λ(*_, **__))[1], lambda *ξ: lambda λ: lambda *_, **__: (print(譯(b'496e76616c6964206f75747075742076616c75652c20657870656374656420257321') % ', '.join(str(σ) for σ in ξ)) if type(r := λ(*_, **__)) not in ξ else '馬鹿', r)[1])[{'in': 0, 'out': 1}.get(型, 'възбудѝ грешка!')])[2] ```
История
Това решение има само една версия.