Domino Chain
Elementary+
English RU

You have a Domino box. Domino tiles contain two numbers from 0 (empty) to 6. Tiles are unordered and 1-6 is the same as 6-1. The double-six set contains 28 unique tiles - all combinations of number pairs.

Several tiles fell out of the box. You should try to line up a chain from these tiles, compiling them to each other's suitable sides (sides with the same numbers). Thus, you can get a continuous chain of tiles. In some cases, such a chain will not be the only one.

For example, you've ended up these tiles:
1-5, 2-5, 3-5, 4-5, 3-4
So, with them you can build two complete chains:
1-5, 5-3, 3-4, 4-5, 5-2
1-5, 5-4, 4-3, 3-5, 5-2

Your goal in this mission is to count how many complete chains you can make using all of the given dominoes.

Note. Chains must be unique. An inverted chain is not considered as unique: "1-2, 2-3, 3-4, 4-5" and "5-4, 4-3, 3-2, 2-1" are the same chain.

Input: String with the description of the domino tiles. Like this one: "5-4, 4-3, 3-2, 2-1".

Output: Integer. The maximum number of complete chains that you can build using all of the given tiles.

Examples:

```domino_chain("0-2, 0-5, 1-5, 1-3, 5-5") == 1
domino_chain("1-5, 2-5, 3-5, 4-5, 3-4") == 2
domino_chain("0-5, 1-5, 2-5, 3-5, 4-5, 3-4") == 0
```

How it is used: This is a combinatorial problem. You can solve it by modeling a real game of dominoes. Or refreshing your knowledge of graph theory. Many things in life resemble the process of forming a domino chain: for example, flights between several cities.

Precondition: 5 <= len(given_tiles) <= 17

## Become Awesome

• No Limits
• More Content
30
Settings
Code:
Other:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

`pip3 install checkio_client`

`checkio --domain=py config --key=`

Sync solutions into your local folder

`checkio sync`

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

`checkio serv -d`

Alternatevly, you can install Chrome extension or FF addon

`checkio install-plugin`
`checkio install-plugin --ff`
`checkio install-plugin --chromium`

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.