Ad
Code
Diff
  • # Only works for x, y > 0 for all x, y in Z
    from math import floor, log10, sqrt
    def add(x, y):
        return floor(sqrt(10**(2*log10(x)) + 2 * 10**(log10(x) + log10(y)) + 10**(2*log10(y))))
    • import numpy
    • # Only works for x, y > 0 for all x, y in Z
    • from math import floor, log10, sqrt
    • def add(x, y):
    • if x == 0 and y == 0:
    • return 0
    • elif y == 0:
    • return add(x - numpy.sign(x), 0) + numpy.sign(x)
    • else:
    • return add(x, y - numpy.sign(y)) + numpy.sign(y)
    • return floor(sqrt(10**(2*log10(x)) + 2 * 10**(log10(x) + log10(y)) + 10**(2*log10(y))))
Code
Diff
  • from math import ceil, log10, sqrt
    
    def add(x, y):
        return ceil(10 ** log10(ceil(sqrt(x**2 + 2*x*y + y**2))))
    • add = lambda x,y: x+y
    • from math import ceil, log10, sqrt
    • def add(x, y):
    • return ceil(10 ** log10(ceil(sqrt(x**2 + 2*x*y + y**2))))
Code
Diff
  • def find_max(arr):
        return sorted(arr)[-1]
    • def find_max(arr):
    • return 0
    • return sorted(arr)[-1]