Nevermind - Damn it, I forgot that you had it in a string, not in int / long / whatever. You can still use the same logic, though ... Just count in binary format, but use only positions containing 1.
Just think out loud.
Take line 1001
, , 1001, 1000, 0001 0000, ?
, , "" .
-
orig = n;
while(n--)
, 1 0:
if(n & !orig)
continue;
, - 1, . , , 1000 1001
, 1, ? 000 111
:
n 0000 0001 | n < 2 0000 1000 | n < 5 1000 0000
:
n 001 | (n 010) * 1000 | (n 100) * 1000 000
, , 1, 1 1 .
- , :)
, - .