33import org .assertj .core .api .InstanceOfAssertFactories ;
44import org .junit .jupiter .api .Test ;
55
6+ import java .util .Arrays ;
67import java .util .List ;
8+ import java .util .stream .Collectors ;
79
810import static org .assertj .core .api .Assertions .assertThat ;
911
1012class DlxTest {
1113 @ Test
1214 void matrixFromFigure3ofPaper_solvedCorrectly () {
1315 Dlx <String > dlx = new Dlx <>(7 , 0 , 10 , false , Integer .MAX_VALUE );
14- dlx .addChoice ("C E F" , List . of (2 , 4 , 5 ));
15- dlx .addChoice ("A D G" , List . of (0 , 3 , 6 ));
16- dlx .addChoice ("B C F" , List . of (1 , 2 , 5 ));
17- dlx .addChoice ("A D" , List . of (0 , 3 ));
18- dlx .addChoice ("B G" , List . of (1 , 6 ));
19- dlx .addChoice ("D E G" , List . of (3 , 4 , 6 ));
16+ dlx .addChoice ("C E F" , listOf (2 , 4 , 5 ));
17+ dlx .addChoice ("A D G" , listOf (0 , 3 , 6 ));
18+ dlx .addChoice ("B C F" , listOf (1 , 2 , 5 ));
19+ dlx .addChoice ("A D" , listOf (0 , 3 ));
20+ dlx .addChoice ("B G" , listOf (1 , 6 ));
21+ dlx .addChoice ("D E G" , listOf (3 , 4 , 6 ));
2022
2123 List <List <String >> solutions = dlx .solve ();
2224
@@ -29,12 +31,12 @@ void matrixFromFigure3ofPaper_solvedCorrectly() {
2931 @ Test
3032 void matrixWithSecondaryConstraint_constraintNotFulfillable_solvedCorrectly () {
3133 Dlx <String > dlx = new Dlx <>(7 , 1 , 10 , false , Integer .MAX_VALUE );
32- dlx .addChoice ("C E F" , List . of (2 , 4 , 5 ));
33- dlx .addChoice ("A D G H" , List . of (0 , 3 , 6 , 7 ));
34- dlx .addChoice ("B C F" , List . of (1 , 2 , 5 ));
35- dlx .addChoice ("A D" , List . of (0 , 3 ));
36- dlx .addChoice ("B G" , List . of (1 , 6 ));
37- dlx .addChoice ("D E G" , List . of (3 , 4 , 6 ));
34+ dlx .addChoice ("C E F" , listOf (2 , 4 , 5 ));
35+ dlx .addChoice ("A D G H" , listOf (0 , 3 , 6 , 7 ));
36+ dlx .addChoice ("B C F" , listOf (1 , 2 , 5 ));
37+ dlx .addChoice ("A D" , listOf (0 , 3 ));
38+ dlx .addChoice ("B G" , listOf (1 , 6 ));
39+ dlx .addChoice ("D E G" , listOf (3 , 4 , 6 ));
3840
3941 List <List <String >> solutions = dlx .solve ();
4042
@@ -47,12 +49,12 @@ void matrixWithSecondaryConstraint_constraintNotFulfillable_solvedCorrectly() {
4749 @ Test
4850 void matrixWithSecondaryConstraint_constraintFulfillable_solvedCorrectly () {
4951 Dlx <String > dlx = new Dlx <>(7 , 1 , 10 , false , Integer .MAX_VALUE );
50- dlx .addChoice ("C E F" , List . of (2 , 4 , 5 ));
51- dlx .addChoice ("A D G" , List . of (0 , 3 , 6 ));
52- dlx .addChoice ("B C F" , List . of (1 , 2 , 5 ));
53- dlx .addChoice ("A D H" , List . of (0 , 3 , 7 ));
54- dlx .addChoice ("B G" , List . of (1 , 6 ));
55- dlx .addChoice ("D E G" , List . of (3 , 4 , 6 ));
52+ dlx .addChoice ("C E F" , listOf (2 , 4 , 5 ));
53+ dlx .addChoice ("A D G" , listOf (0 , 3 , 6 ));
54+ dlx .addChoice ("B C F" , listOf (1 , 2 , 5 ));
55+ dlx .addChoice ("A D H" , listOf (0 , 3 , 7 ));
56+ dlx .addChoice ("B G" , listOf (1 , 6 ));
57+ dlx .addChoice ("D E G" , listOf (3 , 4 , 6 ));
5658
5759 List <List <String >> solutions = dlx .solve ();
5860
@@ -61,4 +63,8 @@ void matrixWithSecondaryConstraint_constraintFulfillable_solvedCorrectly() {
6163 .first (InstanceOfAssertFactories .list (String .class ))
6264 .containsExactlyInAnyOrder ("A D H" , "C E F" , "B G" );
6365 }
66+
67+ private static List <Integer > listOf (int ... args ) {
68+ return Arrays .stream (args ).boxed ().collect (Collectors .toList ());
69+ }
6470}
0 commit comments