I am trying to write a function that will replace characters in a string with their HTML entity encoded equivalent.
I want it to be able to go through all the possible combinations for the given string, for example:
- go one-by-one
- then combo i.e.. 2 at a time, then three at a time, till you get length at a time
- then start in combo split, i.e.. first and last, then first and second to last
- then first and last two, fist and second/third last
So for the characters “abcd” it would return:
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
etc………. so on and so forth till there are no other combinations
Any ideas, or has anyone seen a function somewhere I could modify for this purpose?
loop from 0 to 2^length – 1. On each step, if Nth bit of the loop counter is 1, encode the Nth character