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 6116037
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 262 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 6116037

Please sign in to comment.