private static int solve2(int n) {
        int d = 2;
        int[][] a = new int[101][101];
        int i = 50;
        int j = 50;
        int k = -1;
        int c = 2;
        a[i][j] = 1;
        a[i][j + 1] = 1;
        a[i - 1][j + 1] = 2;
        j++;
        i--;
        while (d <= n) {
            if (k == 1) { // go right
                for (int l = 0; l < c; l++) {
                    a[i][++j] = a[i][j + 1] + a[i][j - 1] + a[i + 1][j] + a[i - 1][j] +
                                a[i + 1][j + 1] + a[i - 1][j - 1] + a[i + 1][j - 1] + a[i - 1][j + 1];
                    d = Math.max(d, a[i][j]);
                    if (d > n)
                        break;
                }
                k = -2;
            } else if (k == -2) { // go up
                for (int l = 0; l < c; l++) {
                    a[--i][j] = a[i][j + 1] + a[i][j - 1] + a[i + 1][j] + a[i - 1][j] +
                                a[i + 1][j + 1] + a[i - 1][j - 1] + a[i + 1][j - 1] + a[i - 1][j + 1];
                    d = Math.max(d, a[i][j]);
                    if (d > n)
                        break;
                }
                c++;
                k = -1;
            } else if (k == -1) { // go left
                for (int l = 0; l < c; l++) {
                    a[i][--j] = a[i][j + 1] + a[i][j - 1] + a[i + 1][j] + a[i - 1][j] +
                                a[i + 1][j + 1] + a[i - 1][j - 1] + a[i + 1][j - 1] + a[i - 1][j + 1];
                    d = Math.max(d, a[i][j]);
                    if (d > n)
                        break;
                }
                k = 2;
            } else { // go down
                for (int l = 0; l < c; l++) {
                    a[++i][j] = a[i][j + 1] + a[i][j - 1] + a[i + 1][j] + a[i - 1][j] +
                                a[i + 1][j + 1] + a[i - 1][j - 1] + a[i + 1][j - 1] + a[i - 1][j + 1];
                    d = Math.max(d, a[i][j]);
                    if (d > n)
                        break;
                }
                k = 1;
                c++;
            }
            printa(a, c + 4);
            System.out.println();
            System.out.println("#####################");
            System.out.println();
        }
        return d;
    }
Why Did you create this class? what does it do?
src/adventofcode/SpiralMemory_3.java