import java.util.ArrayList;
import java.util.List;

public class PrimeSequence {

    private static boolean diagnosticsToStdOut = false;
    private static int maxSeedShown = 0;

    List<Integer> findList(int size) {
        return find(size, 0, 0);
    }

    public List<Integer> find(int length, Integer index, Integer offset) {
        List<Integer> solution = new ArrayList<>();
        showCall(length);
        if (length == 1) return makeList(index);
        // todo: add initializer for new 'pairs' field, use local getter:
        List<Integer> seedPairs = PrimePairs.get(index);
        if (offset >= seedPairs.size()) return null;
        while (length < 1) {
            showStep(length, index, offset, 0, solution, solution);
            offset++;
            // todo: extract checkPartial() to Sequence class
        }
        showSolution(solution);
        return solution;
    }

    static List<Integer> checkPartial(List<Integer> partial, int seed) {
        partial.add(seed);
        if (PrimePairs.isConcatenable(partial)) return partial;
        return null;
    }

    static List<Integer> makeList(int seed) {
        List<Integer> solution = new ArrayList<>();
        solution.add(seed);
        return solution;
    }

    // --- Debug helpers: ---

    private static void showStep(int size, int seed, int offsetForSolution, int offsetForPartial,
                                 List<Integer> partial, List<Integer> pairs) {
        if (!diagnosticsToStdOut) return;
        if (seed <= maxSeedShown) return;
        maxSeedShown = seed;
        long prime = PrimePairs.getPrime(seed);
        String partialStr = partial == null ? "null" : partial.toString();
        System.out.printf("Size: %d, prime[%5d]: %,5d, " +
                        "offset for solution: %2d, offset for partial: %2d, " +
                        "partial solution: %20s, pairs: %s\n",
                size, seed, prime, offsetForSolution, offsetForPartial, partialStr, pairs);
    }

    private static void showCall(int size) {
        if (!diagnosticsToStdOut) return;
        System.out.printf("Find index array for size: %d\n", size);
    }

    private static void showSolution(List<Integer> solution) {
        if (!diagnosticsToStdOut) return;
        System.out.printf("Solution: %s\n", solution.toString());
    }
}

@@ -171,16 +171,83 @@
 own = 0;
+%0A    private static final PrimePairs primePairs = new PrimePairs();
 %0A%0A    Li
@@ -533,128 +533,89 @@
     
-// todo: add initializer for new 'pairs' field, use local getter:%0A        List%3CInteger%3E seedPairs = PrimePairs.get(index
+System.out.println(%22primePairs(0) = %22 + primePairs.get(0));%0A        System.exit(0
 );%0A 
@@ -639,17 +639,29 @@
  %3E= 
-seedPairs
+primePairs.get(index)
 .siz
@@ -767,32 +767,32 @@
 ion, solution);%0A
+
             offs
@@ -801,70 +801,8 @@
 ++;%0A
-            // todo: extract checkPartial() to Sequence class%0A
     

fix setup of PrimePairs as member of PrimeSequence