Ad
Code
Diff
  • def tail_factorial(n, res):
        if n == 0:
            return res
        return tail_factorial(n-1, n*res)
    
    def factorial(num):
        return tail_factorial(num, 1)
    • from math import factorial as code
    • def tail_factorial(n, res):
    • if n == 0:
    • return res
    • return tail_factorial(n-1, n*res)
    • def factorial(wars):
    • return code(wars)
    • def factorial(num):
    • return tail_factorial(num, 1)
Code
Diff
  • is_even = lambda x: not(x & 1)
    • is_even = lambda x: x%2==0
    • is_even = lambda x: not(x & 1)
Code
Diff
  • is_divisible = lambda n, x, y: not n % x and not n % y
    
    • is_divisible = lambda n,x,y:n%x==n%y
    • is_divisible = lambda n, x, y: not n % x and not n % y
Code
Diff
  • is_equal=lambda a,b: ['yes', 'no'][bool(a) ^ bool(b)]
    • is_equal=lambda a,b:'yes'if a==b else'no'
    • is_equal=lambda a,b: ['yes', 'no'][bool(a) ^ bool(b)]