I would like to create set of strings and below is the only limitation.
Same digit should not repeat.
string Range 1-8(12345678) or 1-16(12345678910111213141516)
For example:(set of series)
12345678
12345687
12345876
12345867
...
...
87654321
Like that 2^8(1-8) and 2^16(1-16) possibilities are there.
How can i generate these strings very efficiently with less computation?
Your 8 case is possible but you will quickly run out of space after that.
This is not a
2^ncase like you think it is — it’s ann!case.For 8, there will be 40,320 permutations.
For 16, there will be 20,922,789,888,000 permutations. At 16 bytes / permutation, you’ll need about 304TB to store them.
@kol’s answer should do the permutations for you but I think you need to change your requirements.