Connect in Elixir
Compute the result for a game of Hex / Polygon
exercism fetch elixir connect
Compute the result for a game of Hex / Polygon.
The abstract boardgame known as Hex / 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):
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
O didn't connect top and bottom.
Execute the tests with:
$ elixir bob_test.exs
bob_test.exs with the name of the test file.)
In the test suites, all but the first test have been skipped.
Once you get a test passing, you can unskip the next one by
commenting out the relevant
@tag :pending with a
Or, you can enable all the tests by commenting out the
ExUnit.configure line in the test suite.
# ExUnit.configure exclude: :pending, trace: true
For more detailed information about the Elixir track, please see the help page.
Submitting Incomplete Solutions
It's possible to submit an incomplete solution so you can see how others have completed the exercise.