Created
December 16, 2020 07:28
-
-
Save Rogach/03a0e092df1ffcd9eb92523ee03ac1b5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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