Let's say we have a Set S which contains a few subsets:
- [a,b,c]
- [a,b]
- [c]
- [d,e,f]
- [d,f]
- [e]
Let's also say that S contains six unique elements: a, b, c, d, e and f.
How can we find all possible subsets of S that contain each of the unique elements of S exactly once?
The result of the function/method should be something like that:
[[a,b,c], [d,e,f]];[[a,b,c], [d,f], [e]];[[a,b], [c], [d,e,f]];[[a,b], [c], [d,f], [e]].
Is there any best practice or any standard way to achieve that?
I would be grateful for a Pseudo-code, Ruby or Erlang example.