Skip to content

@huhlig /gist:5025188
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
package playground;
import java.util.ArrayList;
/**
*
*/
public class Playground {
public static ArrayList<ArrayList<Integer>> nextPermutation() {
ArrayList<Integer> storesPermutations = new ArrayList<>(10);
ArrayList<ArrayList<Integer>> storesLists = new ArrayList<>(10);
for (int i = 0; i < 10; i++) {
ArrayList<Integer> allValues = new ArrayList<>(10);
for (int j = 0; j < 10; j++) {
allValues.add(j + 1);
}
while (allValues.size() > 0) {
int storesRand = (int) (Math.random() * (allValues.size()));
int temp = (int) allValues.get(storesRand);
if (storesPermutations.size() < 10) {
storesPermutations.add(temp);
} else {
break;
}
allValues.remove(storesRand);
storesLists.add(storesPermutations);
}
}
return storesLists;
}
public static void main(String[] args) {
ArrayList<ArrayList<Integer>> mainList = nextPermutation();
for (int k = 0; k < 10; k++) {
System.out.println("List " + (k + 1) + ": " + (mainList.get(k)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.