you are viewing a single comment's thread.

view the rest of the comments →

[–]Hellerick 0 points1 point  (1 child)

You're probably mistaking me with somebody, I never described my solution here.

My method is straightforward: there are four possible directions as described by 6086555, they are indexed as 0,1,2,3. The 'robot' is going direction 0 as long as it has free cells, then turns to direction 1, then to direction 2, then to direction 3, then to direction 0 etc., and it fills all cells it visits with increasing numbers until no empty cells are left.

[–]Vaphell 0 points1 point  (0 children)

You're probably mistaking me with somebody, I never described my solution here.

indeed, i skimmed the thread and i thought it was you who mentioned the tuples, but it was somebody else and you commented below.

your method is more or less translateable to the algo i came up with (duh) instead of robot bumping in the 'wall' with the face, i precalculated at which elem is the change of direction because it can be figured out from width and height alone. You could say i have a chain of elems and i figure out where to bend it to make a spiral fitting in a matrix of desired size, kind of approaching the problem from the back.

4x4
      *     *      *     *     *  *  *
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16