I have a string and a number of spaces e.g. the string is "accttgagattcagt" and I have 10 spaces to insert.
How can you iterate over all combinations of that string and spaces? The letters in the string cannot be reordered, and all spaces must be inserted.
And how can you calculate the number of rearrangements (without iterating them)?
And what is the proper word for this? Permutations, combinations or something else?
(I visualise this as strings of 1s and 0s where the 1s are used by the string and the 0s are spaces.
So a short string of 3 letters and 2 spaces would be asking for all all 5 bit numbers with 3 1s and 2 0s e.g. 11100, 11010, 11001, 10110, 10101, 10011, 01110, 01101, 01011, 00111?
But easy as short sequences are to make on paper, I am struggling to make a for-loop to do it :(. So nice pseudocode to create this sequence, and count how long it would be, please?
Recursion will be easier to understand but can it be faster if recursion is avoided somehow?)