32 lines
1.0 KiB
Java
32 lines
1.0 KiB
Java
package com.fabiosalvini;
|
|
|
|
import com.fabiosalvini.permutations.ElementsInputReader;
|
|
import com.fabiosalvini.permutations.PermutationsGenerator;
|
|
import com.fabiosalvini.permutations.PermutationsPrinter;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
printPermutations(readElements());
|
|
}
|
|
|
|
private static long[] readElements() {
|
|
ElementsInputReader inputReader = new ElementsInputReader(System.in);
|
|
try {
|
|
return inputReader.readElements();
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("Error reading elements. Format is: 123,456,789,...", e);
|
|
}
|
|
}
|
|
|
|
private static void printPermutations(long[] elements) {
|
|
try (PermutationsPrinter printer = new PermutationsPrinter(System.out)) {
|
|
PermutationsGenerator generator = new PermutationsGenerator(elements, printer);
|
|
generator.compute();
|
|
} catch (Exception e) {
|
|
throw new RuntimeException("Error printing permutations", e);
|
|
}
|
|
}
|
|
|
|
}
|