Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
2-liner: so much math solution in Clear category for The Nearest Square Number by Stensen
from math import floor, ceil, sqrt, pow
nearest_square = lambda n: pow(min((abs(i-sqrt(n)), i) for i in [floor(sqrt(n)), ceil(sqrt(n))])[1], 2)
Oct. 26, 2020