Hi,
I'm trying to create every permutation of 'injecting' spaces into a string.
For example...
An example input would be "ABC". Each permutation cannot start or end with a space, so there are 4 possible permutations... (i think??)
"ABC"
"AB C"
"A BC"
"A B C"
I've tried something along the following, but not having much luck.
(pseudocode)
MinPerm = Len(strInput)
MaxPerm = Len(strInput) * 2 -1 (minus 1 prevents last character from having a suffixed space)
For Loop = MinPerm To MaxPerm
Binary = GetBinaryString(Loop)
For BinLoop = 1 to Len(Binary)
If Mid(Binary,BinLoop,1) = 0 Then
Output = Output & Mid(position in input string, followed by a space)
Else
Output = Output & Mid(position in input string WITH NO SPACE)
End If
Next
Print Output
Output = ""
Next
I nearly lost the will to live, trying to figure this out so any help would be really appreciated.![]()




??)
Reply With Quote