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
Swap the first and last columns
12709 Solvers
Given an unsigned integer x, find the largest y by rearranging the bits in x
799 Solvers
Number of 1s in a binary string
3033 Solvers
Getting the absolute index from a matrix
213 Solvers
393 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!