Skip to content

Commit

Permalink
killer-sudoku-helper: fix generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Oct 22, 2024
1 parent 1c0971a commit 46106b8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/killer-sudoku-helper/.meta/Example.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module List =
List.map ((@) [ x ]) (combinations (k - 1) xs)
@ combinations k xs

let combinations sum size exclude =
let combinations exclude size sum =
[ 1..9 ]
|> List.except exclude
|> List.combinations size
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module KillerSudokuHelper

let combinations sum size exclude =
let combinations exclude size sum =
failwith "Please implement the 'combinations' function"
36 changes: 14 additions & 22 deletions exercises/practice/killer-sudoku-helper/KillerSudokuHelperTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,53 @@ open KillerSudokuHelper

[<Fact>]
let ``1`` () =
combinations 1 1 [] |> should equal [ [ 1 ] ]
combinations [] 1 1 |> should equal [[1]]

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

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

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

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

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

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

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

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

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

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

[<Fact(Skip = "Remove this Skip property to run this test")>]
let ``Cage with several combinations`` () =
combinations 10 2 []
|> should
equal
[ [ 1; 9 ]
[ 2; 8 ]
[ 3; 7 ]
[ 4; 6 ] ]
combinations [] 2 10 |> should equal [[1; 9]; [2; 8]; [3; 7]; [4; 6]]

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

2 changes: 2 additions & 0 deletions generators/Generators.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2074,6 +2074,8 @@ type ResistorColorTrio() =

type KillerSudokuHelper() =
inherit ExerciseGenerator()

override _.MapTestCase testCase = { testCase with Input = testCase.Input.["cage"].ToObject<Map<string, JToken>>() }

type StateOfTicTacToe() =
inherit ExerciseGenerator()
Expand Down

0 comments on commit 46106b8

Please sign in to comment.