Given array [a, b, c, d, e, f]
I want to match each letter with any other letter except itself, resulting in something like:
- a - c
- b - f
- d - e
The catch is that each letter may be restricted to being matched with one or more of the other letters.
So let's say for example,
- a cannot be matched with c, d
- c cannot be matched with e, f
- e cannot be matched with a
Any guidance on how to go about this? I'm using Ruby, but any pseudo code would be helpful.
Thanks!