Skip to content

Commit

Permalink
Updated readme to explain algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
RGBz committed Jul 31, 2021
1 parent 0a673ba commit c0224eb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ npm start 1x2,2x3,5x6,7x8,11x12,10x1,9x8,3x4,5x4,8x4,9x7,5x7 10
### Details
- Dominoes are represented with the numbered sides separated by an 'x'. e.g.: 1x2 or 10x11
- The first argument to the program must be a comma separated list of dominoes
- The second argument must be the number for the side you're trying to connect to
- The second argument must be the number for the side you're trying to connect to

### How's it work?
This program uses a lazy algorithm to traverse all possible chains given a sequence of dominoes starting from the specified side.

The algorithm has three phases:
1. Find all possible "graphs" for the chain of dominoes. A "graph" in this case is a directed graph from each domino to every other possible domino it could be paired to.
2. Traverse all possible paths for each generated graph starting from the specified side.
3. Return the longest path found from all the paths we've generated.

The graph is represented as a map of side values to all the dominoes that contain that side.

0 comments on commit c0224eb

Please sign in to comment.