Created
May 4, 2018 15:39
-
-
Save amchercashin/8df70242ae686921bc80c6a28b872f3d 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
from math import sqrt, ceil | |
def solve(room_number): | |
s = room_number | |
square_float = 1/2*((sqrt(3)*sqrt(3888*s**2-1)+108*s)**(1/3)/3**(2/3) + 1/(3**(1/3)*(sqrt(3)*sqrt(3888*s**2-1)+108*s)**(1/3)) - 1) | |
level_float = (1/2)*(1+square_float)*square_float | |
square = ceil(square_float) | |
level = ceil(level_float) | |
approx_position = level_float - level + 1 | |
position = round(approx_position / (1/square)) | |
return level, position | |
print(solve(60)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment