Ad
Code
Diff
  • solution = lambda p: (r := 0b11) and [(r := (r >> (_ is True))) for _ in p] and not r
    • def solution(p):
    • return (r := 0b11) and [(r := (r >> (_ is True))) for _ in p] and not r
    • solution = lambda p: (r := 0b11) and [(r := (r >> (_ is True))) for _ in p] and not r

Who doesn't love making code just one line!

Code
Diff
  • solution = lambda param: sum(p is True for p in param) > 1
    • def solution(param: list) -> bool:
    • """Returns True if atleast 2 out of 3 booleans are True."""
    • return sum(p is True for p in param) > 1
    • solution = lambda param: sum(p is True for p in param) > 1
Code
Diff
  • import string
    is_palindrome = lambda s: (x := s.replace(' ', '').lower().translate(str.maketrans('', '', string.punctuation))) == x[::-1]
    • import string
    • def is_palindrome(s: str) -> bool:
    • s = s.replace(' ', '').lower().translate(str.maketrans('', '', string.punctuation))
    • return s == s[::-1]
    • is_palindrome = lambda s: (x := s.replace(' ', '').lower().translate(str.maketrans('', '', string.punctuation))) == x[::-1]