Test case x=[11 22 132] will cause some solutions here to fail.
Great catch! Test case added; and by "some solutions" you mean "All solutions except yours and mine."
@ Tim
Well done, Tim. I noticed the bug of my solution, but it did work for the old test suit, and I was too lazy to fix the bug.
Count from 0 to N^M in base N.
220 Solvers
3986 Solvers
Sum all integers from 1 to 2^n
8441 Solvers
Given a window, how many subsets of a vector sum positive
744 Solvers
267 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!