code: public Permutation setAsPermutation(int upTo) {
          int[] p = new int[upTo];
          for (int i = 0; i < upTo; i++) {
              p[i] = this.cells.get(i).first();
          }
          return new Permutation(p);
      }
docs: Fill the elements of a permutation from the first element of each
  cell, up to the point <code>upTo</code>.
  
  @param upTo take values from cells up to this one
  @return the permutation representing the first element of each cell