Ad
Code
Diff
  • def thousand(n=8):
        return (n << n - 1) - n * 3
    • def thousand(n=8):
    • return int(bin(n)[2:])
    • return (n << n - 1) - n * 3
Code
Diff
  • def thousand(n=8):
        return int(bin(n)[2:])
    • def thousand(n=8):
    • x = [n * 5, n * 10, n * 100]
    • return sum(x) + x[1]
    • return int(bin(n)[2:])
Fundamentals

-4

Code
Diff
  • numberprint=lambda x:int(''.join(map(str,(m:=list(range(1,x+1)))+m[-2::-1])))   
    
    • numberprint=lambda x,l=list,r=range:int(''.join(map(str,l(r(1,x))+l(r(x,0,-1)))))
    • numberprint=lambda x:int(''.join(map(str,(m:=list(range(1,x+1)))+m[-2::-1])))
Code
Diff
  • f=lambda n:[n-10,91][n<101]
    • f=lambda n: 91 if n <= 100 else n - 10
    • f=lambda n:[n-10,91][n<101]
Fundamentals
Strings
Data Types
Algorithms
Logic
Code
Diff
  • palindrome = lambda q: q[:(l:=len(q)>>1)] == q[-1 : ~l : -1]
    • def palindrome(word):return True if word == word[::-1] else False
    • palindrome = lambda q: q[:(l:=len(q)>>1)] == q[-1 : ~l : -1]
Arithmetic
Mathematics
Algorithms
Logic
Numbers
Code
Diff
  • sum_last_two_items = lambda x: x.pop()+x.pop()
    • sum_last_two_items = lambda x: sum(x[-2:])
    • sum_last_two_items = lambda x: x.pop()+x.pop()
Fundamentals
Strings
Data Types
Algorithms
Logic
Code
Diff
  • palindrome = lambda w: (s:=str(w))[:(l:=len(s)>>1)] == s[:~l:-1]
    
    • palindrome = lambda w: str(w)[::-1] == str(w)
    • palindrome = lambda w: (s:=str(w))[:(l:=len(s)>>1)] == s[:~l:-1]
Code
Diff
  • is_even = lambda x: ~x&1
    
    • is_even = lambda x: ~x%2
    • is_even = lambda x: ~x&1
Fundamentals
Code
Diff
  • numberprint=lambda x:int(''.join(map(str,__import__("itertools").chain((m:=range(1, x + 1)),m[-2::-1]))))
    
    • def numberprint(x):
    • return int(''.join(map(lambda x: str(x), list(range(1, x + 1)) + list(range(x - 1, 0, -1)))))
    • # harder to read but 1 line ¯\_(ツ)_/¯
    • numberprint=lambda x:int(''.join(map(str,__import__("itertools").chain((m:=range(1, x + 1)),m[-2::-1]))))
Fundamentals
Code
Diff
  • def numberprint(x):
        l1 = list(map(str, range(1, x + 1)))
        l1.extend(l1[-2::-1])
        return int(''.join(l1))
    • def numberprint(x):
    • l1 = [str(i) for i in range(1, x + 1)]
    • l2 = [str(i) for i in range(x - 1, 0, -1)]
    • l1 += l2
    • return int("".join(l1))
    • l1 = list(map(str, range(1, x + 1)))
    • l1.extend(l1[-2::-1])
    • return int(''.join(l1))
Code
Diff
  • reverse_compliment= lambda dna:(''.join(list(reversed(dna)))).translate(str.maketrans("ACGT", "TGCA"))
    • t = str.maketrans("ACGTacgt", "TGCATGCA")
    • reverse_compliment = lambda dna: "".join(chr(t[ord(x)]) for x in reversed(dna))
    • reverse_compliment= lambda dna:(''.join(list(reversed(dna)))).translate(str.maketrans("ACGT", "TGCA"))