Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Capped triangle wave solution in Creative category for Square Board by PythonWithPI
from typing import Tuple
Coordinate = Tuple[int, int]
def square_board(side: int, token: int, steps: int) -> Coordinate:
#lower right is (side,side)
#https://www.desmos.com/calculator/k6q0eyhyxv
#Function designed in desmos, used a
#https://en.wikipedia.org/wiki/Triangle_wave#Definitions
#modulus triangle wave capped at 0 and s so it would represent the coordinates properly.
#Then I shifted it over for the other side.
t=steps+token
s=side-1
return (max(min(abs((t-s/2)%(4*s)-2*s)-s/2,s),0),max(min(abs((t+s/2)%(4*s)-2*s)-s/2,s),0))
Feb. 13, 2019