Ad
Code
Diff
  • from math import sqrt
    def divisors(n):
        fa={i for i in range(1,int(sqrt(n)) + 1) if not(n%i)}
        ct={n//i for i in fa}
        return sorted(fa|ct)
    • from math import sqrt
    • def divisors(n):
    • fact = []
    • for i in range(1, int(n**0.5) + 1):
    • if not(n % i):
    • v = n // i
    • if v != i:
    • fact.insert(len(fact)//2,v)
    • fact.insert(len(fact)//2,i)
    • return fact
    • fa={i for i in range(1,int(sqrt(n)) + 1) if not(n%i)}
    • ct={n//i for i in fa}
    • return sorted(fa|ct)

being smarter

Code
Diff
  • from math import *
    def hypotenuse(a, b): return hypot(a,b)
        
    • def hypotenuse(a, b):
    • return abs(a + b * 1j)
    • from math import *
    • def hypotenuse(a, b): return hypot(a,b)