Skip to content

Commit f9a14ba

Browse files
authored
Merge pull request #665 from petertseng/go-counting
go-counting 1.0.0.3: Match new canonical data exercism/problem-specifications#1195
2 parents 4e738b0 + 05f9505 commit f9a14ba

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

exercises/go-counting/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Write a function that determines the territory of each player. You may
1111
assume that any stones that have been stranded in enemy territory have
1212
already been taken off the board.
1313

14+
Write a function that determines the territory which includes a specified coordinate.
15+
1416
Multiple empty intersections may be encircled at once and for encircling
1517
only horizontal and vertical neighbours count. In the following diagram
1618
the stones which matter are marked "O" and the stones that don't are

exercises/go-counting/package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: go-counting
2-
version: 0.1.0.2
2+
version: 1.0.0.3
33

44
dependencies:
55
- base

exercises/go-counting/test/Tests.hs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ specs = do
1919
, " W W "
2020
, " W " ]
2121

22-
board9x9 = [ " B B "
23-
, "B B B"
24-
, "WBBBWBBBW"
25-
, "W W W W W"
26-
, " "
27-
, " W W W W "
28-
, "B B B B"
29-
, " W BBB W "
30-
, " B B " ]
31-
3222
shouldHaveTerritories = shouldMatchList
3323
. map (first toAscList)
3424
. territories
@@ -54,33 +44,39 @@ specs = do
5444
, ([ (4, 1)
5545
, (4, 2) ], Just White) ]
5646

47+
it "two territories of same player, rectangular board" $
48+
[ " B " ] `shouldHaveTerritories` [ ([ (1, 1) ], Just Black)
49+
, ([ (3, 1) ], Just Black) ]
50+
5751
it "5x5 score" $
5852
board5x5 `shouldScore` [ (Nothing , 9)
5953
, (Just Black, 6)
6054
, (Just White, 1) ]
6155

62-
it "5x5 territory for black" $
56+
it "5x5 territory for black bordering edge" $
6357
territoryIn board5x5 (1, 2) `shouldBe` Just ([ (1, 1)
6458
, (1, 2)
6559
, (2, 1) ], Just Black)
6660

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

70-
it "5x5 open territory" $
64+
it "5x5 open territory bordering edge" $
7165
territoryIn board5x5 (2, 5) `shouldBe` Just ([ (1, 4)
7266
, (1, 5)
7367
, (2, 5) ], Nothing)
7468

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

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

81-
it "5x5 non-territory (too high coordinate)" $
82-
territoryIn board5x5 (2, 6) `shouldBe` Nothing
75+
it "5x5 non-territory (X too high)" $
76+
territoryIn board5x5 (6, 2) `shouldBe` Nothing
8377

84-
it "9x9 score" $
85-
board9x9 `shouldScore` [ (Nothing , 33)
86-
, (Just Black, 14) ]
78+
it "5x5 non-territory (Y too low)" $
79+
territoryIn board5x5 (2, 0) `shouldBe` Nothing
80+
81+
it "5x5 non-territory (Y too high)" $
82+
territoryIn board5x5 (2, 6) `shouldBe` Nothing

0 commit comments

Comments
 (0)