Generate java combination (ArCombination)

Table of Contents ⇒ Java Algorithm Library-Artery-Sample

package jp.avaj.lib.algo;

import java.util.List;

import jp.avaj.lib.test.L;

/**
combination(ArCombination)

Use the ArCombination class to generate combinations.
Season in this sample(ArSeason)Get two combinations from.
 */
public class Q08_00 {
  public static void main(String[] args) {

    ArCombination<ArSeason> combi = new ArCombination<ArSeason>(ArSeason.values());

    //Generate a combination
    List<List<ArSeason>> list = combi.create(2);
    //Check the result
    for (List<ArSeason> item : list) {
      L.p("item="+item.toString());
    }
  }
}

result.txt


item=[spring,summer]
item=[spring,autumn]
item=[spring,winter]
item=[summer,autumn]
item=[summer,winter]
item=[autumn,winter]

Recommended Posts

Generate java combination (ArCombination)
Combination calculation (Pascal's triangle) (Java)
[Java] I implemented the combination.
Generate CloudStack API URL in Java
Java
Java