Skip to content

Commit

Permalink
state-of-tic-tac-toe: fix generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Oct 22, 2024
1 parent 46106b8 commit 0c2815a
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 256 deletions.
14 changes: 8 additions & 6 deletions exercises/practice/state-of-tic-tac-toe/.meta/Example.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ type Board = Cell [,]
let won (player: Cell) (board: Board) =
let winning = [| player; player; player |]

Array.init 3 (fun i -> board[i, i]) = winning ||
Array.init 3 (fun i -> board[i, 2 - i]) = winning
|| Array.init 3 (fun i -> board[i, *]) |> Array.contains winning
|| Array.init 3 (fun i -> board[*, i]) |> Array.contains winning

let gameState (board: Board) =
Array.init 3 (fun i -> board[i, i]) = winning
|| Array.init 3 (fun i -> board[i, 2 - i]) = winning
|| Array.init 3 (fun i -> board[i, *])
|> Array.contains winning
|| Array.init 3 (fun i -> board[*, i])
|> Array.contains winning

let gamestate (board: Board) =
let numCells cell =
board
|> Seq.cast
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module StateOfTicTacToe
// TODO: define the 'EndGameState' type
// TODO: define the 'GameError' type

let gameState board =
let gamestate board =
failwith "Please implement the 'gameState' function"
Loading

0 comments on commit 0c2815a

Please sign in to comment.