Skip to content

Instantly share code, notes, and snippets.

@Rogach
Created December 16, 2020 07:28
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 Rogach/03a0e092df1ffcd9eb92523ee03ac1b5 to your computer and use it in GitHub Desktop.
Save Rogach/03a0e092df1ffcd9eb92523ee03ac1b5 to your computer and use it in GitHub Desktop.
import sys
import math
range_min = int(sys.argv[1])
range_max = int(sys.argv[2])
def calculate_square_depth(range_min, range_max):
if range_max <= 3:
return 0
min_bound = math.ceil(range_min**0.5)
max_bound = math.floor(range_max**0.5)
if max_bound < min_bound:
return 0
else:
return 1 + calculate_square_depth(min_bound, max_bound)
print(calculate_square_depth(range_min, range_max))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment