static void spiralMatrix(int n) {
		if (n <= 0) {
			System.out.println("Input has to be bigger than 0. Passed in: " + n);
		}
		int[][] arr = new int[n][n];
		int[] dir = {1, 0};
		int x = 0; int y = 0;
		
		for (int i = n*n; i > 0; --i) {
			arr[y][x] = i;
			if (x + dir[0] >= n || y + dir[1] >= n || 
				x + dir[0] < 0 || y + dir[1] < 0 ||
				arr[y + dir[1]][x + dir[0]] != 0) {
				dir = changeDir(dir);
			}
			
			x += dir[0];
			y += dir[1];
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				System.out.print(arr[i][j] + " ");
			}
			System.out.println();
		}
	}