YOU arrow keys / WASD
cells 1/12dir: RIGHT →
output: [1]
SNAKEBOT Kodee's code plays itself
cells 1/12dir: RIGHT →for col = left .. right
output: [1]
Turn clockwise: right, down, left, up, and again. After every side, that wall moves one step in. That is all SnakeBot knows.
top = 0, bottom = rows - 1, left = 0, right = cols - 1 while (top <= bottom && left <= right) { for col = left .. right: take matrix[top][col] // → top++ for row = top .. bottom: take matrix[row][right] // ↓ right-- if (top <= bottom) for col = right .. left: take matrix[bottom][col] // ← bottom-- if (left <= right) for row = bottom .. top: take matrix[row][left] // ↑ left++ }