snake/spiral traversal of 2d array