@Override
    public Integer solve() {

        final List<Integer> primes = primes(1000000);
        
        for (int prime : primes) {
            for (List<Integer> pattern : findPatterns(prime)) {
                
                final char[] c = Integer.toString(prime).toCharArray();
                int total = 0;
                final List<Integer> list = new ArrayList<Integer>();
                for (char digit : DIGITS) {
                    for (int i : pattern) {
                        c[(c.length - 1) - i] = digit;
                    }
                    ++total;
                    int n = Integer.parseInt(String.valueOf(c));
                    if (isPrime(n, primes)) list.add(n);
                    if (total - list.size() > 2) break;
                }
                if (list.size() >= 8) {
                    if (String.valueOf(list.get(0)).length() == String.valueOf(prime).length()) {
                        return list.get(0);
                    }
                }
            }
        }
        
        return null;
    }