Sha256: 7d79685f420e9dd42f2c8bbeb1a720c15f944939f31091d04e4c2e35eb1acf96

Contents?: true

Size: 1.72 KB

Versions: 75

Compression:

Stored size: 1.72 KB

Contents

# Connect

Compute the result for a game of Hex / Polygon.

The abstract boardgame known as
[Hex](https://en.wikipedia.org/wiki/Hex_%28board_game%29) / Polygon /
CON-TAC-TIX is quite simple in rules, though complex in practice. Two players
place stones on a rhombus with hexagonal fields. The player to connect his/her
stones to the opposite side first wins. The four sides of the rhombus are
divided between the two players (i.e. one player gets assigned a side and the
side directly opposite it and the other player gets assigned the two other
sides).

Your goal is to build a program that given a simple representation of a board
computes the winner (or lack thereof). Note that all games need not be "fair".
(For example, players may have mismatched piece counts.)

The boards look like this (with spaces added for readability, which won't be in
the representation passed to your code):

```text
. O . X .
 . X X O .
  O O O X .
   . X O X O
    X O O O X
```

"Player `O`" plays from top to bottom, "Player `X`" plays from left to right. In
the above example `O` has made a connection from left to right but nobody has
won since `O` didn't connect top and bottom.


## Running the tests

1. Go to the root of your PHP exercise directory, which is `<EXERCISM_WORKSPACE>/php`.
   To find the Exercism workspace run

        % exercism debug | grep Workspace

1. Get [PHPUnit] if you don't have it already.

        % wget --no-check-certificate https://phar.phpunit.de/phpunit.phar
        % chmod +x phpunit.phar

2. Execute the tests:

        % ./phpunit.phar connect/connect_test.php

[PHPUnit]: http://phpunit.de


## Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/php/exercises/connect/README.md
trackler-2.2.1.138 tracks/php/exercises/connect/README.md
trackler-2.2.1.137 tracks/php/exercises/connect/README.md
trackler-2.2.1.136 tracks/php/exercises/connect/README.md
trackler-2.2.1.135 tracks/php/exercises/connect/README.md
trackler-2.2.1.134 tracks/php/exercises/connect/README.md
trackler-2.2.1.133 tracks/php/exercises/connect/README.md
trackler-2.2.1.132 tracks/php/exercises/connect/README.md
trackler-2.2.1.131 tracks/php/exercises/connect/README.md
trackler-2.2.1.130 tracks/php/exercises/connect/README.md
trackler-2.2.1.129 tracks/php/exercises/connect/README.md
trackler-2.2.1.128 tracks/php/exercises/connect/README.md
trackler-2.2.1.127 tracks/php/exercises/connect/README.md
trackler-2.2.1.126 tracks/php/exercises/connect/README.md
trackler-2.2.1.125 tracks/php/exercises/connect/README.md
trackler-2.2.1.124 tracks/php/exercises/connect/README.md
trackler-2.2.1.123 tracks/php/exercises/connect/README.md
trackler-2.2.1.122 tracks/php/exercises/connect/README.md
trackler-2.2.1.121 tracks/php/exercises/connect/README.md
trackler-2.2.1.120 tracks/php/exercises/connect/README.md