Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
5-liner: don't iterate, calculate only solution in Clear category for Square Board by przemyslaw.daniel
def square_board(length, start, steps):
side, pos = divmod(start+steps, length-1)
x, y = [(-1, -1-pos), (-1-pos, 0),
(0, pos), (pos, -1)][side % 4]
return x % length, y % length
Jan. 24, 2019
Comments: