Help with the algorithm. I'm sure there's math on Peekaboo

 

v20240901