Snake (spiral) traversal of 2d array