3

Given the matrix A x A and a number of movements N.

And walking like a spiral:

  1. right while possible, then
  2. down while possible, then
  3. left while possible, then
  4. up while possible, repeat until got N.

Image with example (A = 8; N = 36)

enter image description here

In this example case, the final square is (4; 7).

My question is: Is it possible to use a generic formula to solve this?

John B
  • 16,854
removed
  • 131
  • Do you mean to ask whether there is a closed-form expression for both the row and the column of the last square? – Brian Tung Nov 06 '15 at 03:20
  • @BrianTung. Actually, (A = 8; N = 36) are very very low numbers. The closest I can get to N would be nice. – removed Nov 06 '15 at 03:24
  • Well, whether or not there's a closed-form expression isn't affected by how large the numbers are. – Brian Tung Nov 06 '15 at 03:25
  • @Sorry I don't have a simple hint to give for your question (I deleted my answer because I misread it). But almost certainly you need the absolute value function, the floor function and square-roots (possibly modulo) because it's somewhat quadratic behaviour. – user21820 Nov 06 '15 at 03:32
  • Thank you guys.. I got one solution here: http://stackoverflow.com/a/33575439/4227915 – removed Nov 09 '15 at 11:03

0 Answers0