private static int maxProduct() {
        int horizontal = -1, vertical = -1, diagonal1 = -1, diagonal2 = -1, max = 0;
        for (int i = 0; i < 20; i++) {
            for (int j = 0; j < 20; j++) {
                if (i + 3 < 20)
                    vertical = num(i, j) * num(i + 1, j) * num(i + 2, j) * num(i + 3, j);
                if (j + 3 < 20)
                    horizontal = num(i, j) * num(i, j + 1) * num(i, j + 2) * num(i, j + 3);
                if (i + 3 < 20 && j + 3 < 20)
                    diagonal1 = num(i, j) * num(i + 1, j + 1) * num(i + 2, j + 2) * num(i + 3, j + 3);
                if (i - 3 >= 0 && j + 3 < 20)
                    diagonal2 = num(i, j) * num(i - 1, j + 1) * num(i - 2, j + 2) * num(i - 3, j + 3);
                max = max5(horizontal, vertical, diagonal1, diagonal2, max);
            }
        }
        return max;
    }