Skip to content

go-counting 1.0.0.3: Match new canonical data #665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions exercises/go-counting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Write a function that determines the territory of each player. You may
assume that any stones that have been stranded in enemy territory have
already been taken off the board.

Write a function that determines the territory which includes a specified coordinate.

Multiple empty intersections may be encircled at once and for encircling
only horizontal and vertical neighbours count. In the following diagram
the stones which matter are marked "O" and the stones that don't are
Expand Down
2 changes: 1 addition & 1 deletion exercises/go-counting/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: go-counting
version: 0.1.0.2
version: 1.0.0.3

dependencies:
- base
Expand Down
34 changes: 15 additions & 19 deletions exercises/go-counting/test/Tests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ specs = do
, " W W "
, " W " ]

board9x9 = [ " B B "
, "B B B"
, "WBBBWBBBW"
, "W W W W W"
, " "
, " W W W W "
, "B B B B"
, " W BBB W "
, " B B " ]

shouldHaveTerritories = shouldMatchList
. map (first toAscList)
. territories
Expand All @@ -54,33 +44,39 @@ specs = do
, ([ (4, 1)
, (4, 2) ], Just White) ]

it "two territories of same player, rectangular board" $
[ " B " ] `shouldHaveTerritories` [ ([ (1, 1) ], Just Black)
, ([ (3, 1) ], Just Black) ]

it "5x5 score" $
board5x5 `shouldScore` [ (Nothing , 9)
, (Just Black, 6)
, (Just White, 1) ]

it "5x5 territory for black" $
it "5x5 territory for black bordering edge" $
territoryIn board5x5 (1, 2) `shouldBe` Just ([ (1, 1)
, (1, 2)
, (2, 1) ], Just Black)

it "5x5 territory for white" $
it "5x5 territory for white not bordering edge" $
territoryIn board5x5 (3, 4) `shouldBe` Just ([ (3, 4) ], Just White)

it "5x5 open territory" $
it "5x5 open territory bordering edge" $
territoryIn board5x5 (2, 5) `shouldBe` Just ([ (1, 4)
, (1, 5)
, (2, 5) ], Nothing)

it "5x5 non-territory (stone)" $
territoryIn board5x5 (2, 2) `shouldBe` Nothing

it "5x5 non-territory (too low coordinate)" $
it "5x5 non-territory (X too low)" $
territoryIn board5x5 (0, 2) `shouldBe` Nothing

it "5x5 non-territory (too high coordinate)" $
territoryIn board5x5 (2, 6) `shouldBe` Nothing
it "5x5 non-territory (X too high)" $
territoryIn board5x5 (6, 2) `shouldBe` Nothing

it "9x9 score" $
board9x9 `shouldScore` [ (Nothing , 33)
, (Just Black, 14) ]
it "5x5 non-territory (Y too low)" $
territoryIn board5x5 (2, 0) `shouldBe` Nothing

it "5x5 non-territory (Y too high)" $
territoryIn board5x5 (2, 6) `shouldBe` Nothing