Sha256: 93ffe2a0e2c96747803440391e7bf79b15b17003cc1a9e95299ed39edbc0bb2c

Contents?: true

Size: 1.89 KB

Versions: 79

Compression:

Stored size: 1.89 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.

* * * *

For installation and learning resources, refer to the
[exercism help page](http://exercism.io/languages/ruby).

For running the tests provided, you will need the Minitest gem. Open a
terminal window and run the following command to install minitest:

    gem install minitest

If you would like color output, you can `require 'minitest/pride'` in
the test file, or note the alternative instruction, below, for running
the test file.

Run the tests from the exercise directory using the following command:

    ruby connect_test.rb

To include color from the command line:

    ruby -r minitest/pride connect_test.rb


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

Version data entries

79 entries across 79 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.118 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.117 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.116 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.115 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.114 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.113 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.111 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.110 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.109 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.108 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.107 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.106 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.105 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.104 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.103 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.102 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.101 tracks/ruby/exercises/connect/README.md
trackler-2.2.1.100 tracks/ruby/exercises/connect/README.md