public class RandomShift implements ShiftInterface { @Override public void shift(SwapStoreInterface ss) { for (int i = 0; i < ss.length(); i++) { ss.setShifts(i, randomShifts(ss.lineIndices(i))); } } private int[][] randomShifts(int[] indices) { int[][] result = new int[(int) Math.round(Math.random()*indices.length)][]; for (int i = 0; i < result.length; i++) { result[i] = new int[(int) Math.round(Math.random()*indices.length)]; for (int j = 0; j < result[i].length; j++) { result[i][j] = indices[(int) Math.round(Math.random()*(indices.length -1))]; } } return result; } }