My solutions for google foobar
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1016 B

#I might over-comment those solutions since it might be
#reviewed one day, so bear with me, reviewers!
Gets the biggest square below or equal to max_number
I'm sure it can be optimized but as we never get over 1M
it should be largely fast enough for most cpus:
➜ /tmp time python2
python2 0.01s user 0.00s system 96% cpu 0.009 total
The code is also more readable this way
def get_biggest_square(max_number):
while(n*n < max_number+1):
return n-1
#Check readme.txt for an explaination of what this does.
# "Heavy" computation is done in get_biggest_square
def answer(area):
#check readme.txt
if(area > 1000000 or area < 1):
raise ValueError('Area is outside of bounds')
#no need to sort or do fancy pant stuff, we go from biggest to smallest in
#a natural fashion this way
while(area != 0):
return array