Created
April 30, 2020 12:59
-
-
Save CITGuru/fbd8f5872a7b8eb1eb62ded3e16d936b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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