Set, the card game: Difference between revisions

(New post.)
Line 173:
private static List<Card> createPackOfCards() {
List<Card> pack = new ArrayList<Card>(81);
for ( Number number : Number.values() ) {
for ( Colour colour : Colour.values() ) {
Line 198:
}
private static <T> List<List<T>> combinations(List<T> list, int rchoose) {
List<List<T>> combinations = new ArrayList<List<T>>();
List<Integer> combination = IntStream.range(0, rchoose).boxed().collect(Collectors.toList());
while ( combination.get(rchoose - 1) < list.size() ) {
combinations.add(combination.stream().map( i -> list.get(i) ).toList());
int ttemp = rchoose - 1;
while ( ttemp != 0 && combination.get(ttemp) == list.size() - rchoose + ttemp ) {
t-temp -= 1;
}
combination.set(ttemp, combination.get(ttemp) + 1);
for ( int i = ttemp + 1; i < rchoose; i++ ) {
combination.set(i, combination.get(i - 1) + 1);
}
908

edits