Skip to content

Instantly share code, notes, and snippets.

@CITGuru
Created April 30, 2020 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CITGuru/fbd8f5872a7b8eb1eb62ded3e16d936b to your computer and use it in GitHub Desktop.
Save CITGuru/fbd8f5872a7b8eb1eb62ded3e16d936b to your computer and use it in GitHub Desktop.
import timeit
print("GeekyAdams")
print("https://gist.github.com/GeekyADAMS/85af9d7de96b37688ef432bcfe499b6c")
code_to_test = """
from math import sqrt, pow
def solution(area):
result = []
while area > 0:
# uses a non perfect square to get nearest perfect square
large_area = pow((int(sqrt(area))), 2) # or int(area**.5) ** 2
area -= large_area
result.append(int(large_area))
return result
print(solution(15324))
print(solution(12))
print(solution(2982))
print(solution(9))
"""
elapsed_time = timeit.timeit(code_to_test, number=1)/100
print("Code took: ", elapsed_time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment