I think that with this kind of problem, you can process in two steps.
A first easy problem with small N (to test perms for example). And a harder problem with big N, which
oblige to find another algorithm.
http://oeis.org/A000166
1837 Solvers
Get the area codes from a list of phone numbers
532 Solvers
272 Solvers
Combinations without using nchoosek
66 Solvers
255 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!