Skip to content

Commit 46106b8

Browse files
killer-sudoku-helper: fix generator
1 parent 1c0971a commit 46106b8

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

exercises/practice/killer-sudoku-helper/.meta/Example.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module List =
99
List.map ((@) [ x ]) (combinations (k - 1) xs)
1010
@ combinations k xs
1111

12-
let combinations sum size exclude =
12+
let combinations exclude size sum =
1313
[ 1..9 ]
1414
|> List.except exclude
1515
|> List.combinations size
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module KillerSudokuHelper
22

3-
let combinations sum size exclude =
3+
let combinations exclude size sum =
44
failwith "Please implement the 'combinations' function"

exercises/practice/killer-sudoku-helper/KillerSudokuHelperTests.fs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,53 @@ open KillerSudokuHelper
77

88
[<Fact>]
99
let ``1`` () =
10-
combinations 1 1 [] |> should equal [ [ 1 ] ]
10+
combinations [] 1 1 |> should equal [[1]]
1111

1212
[<Fact(Skip = "Remove this Skip property to run this test")>]
1313
let ``2`` () =
14-
combinations 2 1 [] |> should equal [ [ 2 ] ]
14+
combinations [] 1 2 |> should equal [[2]]
1515

1616
[<Fact(Skip = "Remove this Skip property to run this test")>]
1717
let ``3`` () =
18-
combinations 3 1 [] |> should equal [ [ 3 ] ]
18+
combinations [] 1 3 |> should equal [[3]]
1919

2020
[<Fact(Skip = "Remove this Skip property to run this test")>]
2121
let ``4`` () =
22-
combinations 4 1 [] |> should equal [ [ 4 ] ]
22+
combinations [] 1 4 |> should equal [[4]]
2323

2424
[<Fact(Skip = "Remove this Skip property to run this test")>]
2525
let ``5`` () =
26-
combinations 5 1 [] |> should equal [ [ 5 ] ]
26+
combinations [] 1 5 |> should equal [[5]]
2727

2828
[<Fact(Skip = "Remove this Skip property to run this test")>]
2929
let ``6`` () =
30-
combinations 6 1 [] |> should equal [ [ 6 ] ]
30+
combinations [] 1 6 |> should equal [[6]]
3131

3232
[<Fact(Skip = "Remove this Skip property to run this test")>]
3333
let ``7`` () =
34-
combinations 7 1 [] |> should equal [ [ 7 ] ]
34+
combinations [] 1 7 |> should equal [[7]]
3535

3636
[<Fact(Skip = "Remove this Skip property to run this test")>]
3737
let ``8`` () =
38-
combinations 8 1 [] |> should equal [ [ 8 ] ]
38+
combinations [] 1 8 |> should equal [[8]]
3939

4040
[<Fact(Skip = "Remove this Skip property to run this test")>]
4141
let ``9`` () =
42-
combinations 9 1 [] |> should equal [ [ 9 ] ]
42+
combinations [] 1 9 |> should equal [[9]]
4343

4444
[<Fact(Skip = "Remove this Skip property to run this test")>]
4545
let ``Cage with sum 45 contains all digits 1:9`` () =
46-
combinations 45 9 []
47-
|> should equal [ [ 1; 2; 3; 4; 5; 6; 7; 8; 9 ] ]
46+
combinations [] 9 45 |> should equal [[1; 2; 3; 4; 5; 6; 7; 8; 9]]
4847

4948
[<Fact(Skip = "Remove this Skip property to run this test")>]
5049
let ``Cage with only 1 possible combination`` () =
51-
combinations 7 3 []
52-
|> should equal [ [ 1; 2; 4 ] ]
50+
combinations [] 3 7 |> should equal [[1; 2; 4]]
5351

5452
[<Fact(Skip = "Remove this Skip property to run this test")>]
5553
let ``Cage with several combinations`` () =
56-
combinations 10 2 []
57-
|> should
58-
equal
59-
[ [ 1; 9 ]
60-
[ 2; 8 ]
61-
[ 3; 7 ]
62-
[ 4; 6 ] ]
54+
combinations [] 2 10 |> should equal [[1; 9]; [2; 8]; [3; 7]; [4; 6]]
6355

6456
[<Fact(Skip = "Remove this Skip property to run this test")>]
6557
let ``Cage with several combinations that is restricted`` () =
66-
combinations 10 2 [ 1; 4 ]
67-
|> should equal [ [ 2; 8 ]; [ 3; 7 ] ]
58+
combinations [1; 4] 2 10 |> should equal [[2; 8]; [3; 7]]
59+

generators/Generators.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,8 @@ type ResistorColorTrio() =
20742074

20752075
type KillerSudokuHelper() =
20762076
inherit ExerciseGenerator()
2077+
2078+
override _.MapTestCase testCase = { testCase with Input = testCase.Input.["cage"].ToObject<Map<string, JToken>>() }
20772079

20782080
type StateOfTicTacToe() =
20792081
inherit ExerciseGenerator()

0 commit comments

Comments
 (0)