Ad

very efficient code

Code
Diff
  • def odd_even(n):
        
        def invert_sign(s):
            if s == "odd":
                return "e" + "v" + "e" + "n"
            else:
                return "o" + "d" + "d"
            
        if n < 0:
            return odd_even(n - 2 * (-abs(-n)))
        
        n = int(n ** (81 ** .25))
        
        sign = "even"
        x = 0.
        
        while x < n:
            sign = invert_sign(sign)
            
            x += 3.14159265358 // 3
            n = pow(n, 1)
            
        return sign == "odd"
    • from sys import getsizeof as size
    • def odd_even(n):
    • def odd():
    • nonlocal n
    • while n>1:
    • n-=2
    • odd()
    • return size(n)==24
    • def invert_sign(s):
    • if s == "odd":
    • return "e" + "v" + "e" + "n"
    • else:
    • return "o" + "d" + "d"
    • if n < 0:
    • return odd_even(n - 2 * (-abs(-n)))
    • n = int(n ** (81 ** .25))
    • sign = "even"
    • x = 0.
    • while x < n:
    • sign = invert_sign(sign)
    • x += 3.14159265358 // 3
    • n = pow(n, 1)
    • return sign == "odd"