def listBeautifier(a): res = a[:] while res and res[0] != res[-1]: b, *res, c = res return res
Previous
def listBeautifier(a): res = a[:] while res and res[0] != res[-1]: b, *res, c = res return res
def mexFunction(s, upperBound): found = -1 for i in range(upperBound): if not i in s: found = i break else: found = upperBound return found
def baseConversion(n, x): return hex(sum((int(n[i]) if n[i] <= '9' else ord(n[i]) - ord('a') + 10) * x ** (len(n) - 1 - i) for i in range(len(n))))[2:]
def simpleSort(arr): n = len(arr) for i in range(n): j = 0 stop = n - i while j < stop - 1: if arr[j] > arr[j + 1]: arr[j + 1], arr[j] = arr[j], arr[j + 1] j += 1 return arr
import time L = 1 x = 2 y = 3 R = 9 t1 = time.perf_counter() def a(): if L < x ** y <= R: return True t2 = time.perf_counter() print(t2 - t1) t3 = time.perf_counter() def b(): if x ** y > L and x ** y <= R: return True t4 = time.perf_counter() print(t4 - t3) t5 = time.perf_counter() def c(): if x ** y in range(L + 1, R + 1): return True t6 = time.perf_counter() print(t6 - t5)
5.131850057605017e-07 1.5395550172814964e-06 1.5395550172815045e-05