In article <PMKdnewsJbCz_bXVnZ2dnUVZ_tTinZ2d@[EMAIL PROTECTED]
>,
Jeff Dege <jdege@[EMAIL PROTECTED]
> wrote:
>I'm looking for a way to generate all of the possible complete partitions
>of a string.
>
>That is, if I have a string "ABCD", I want to generate the list:
>
>"ABCD"
>"ABC" "D"
>"AB" "CD"
>"AB" "C" "D"
>"A" "BCD"
>"A" "BC" "D"
>"A" "B" "CD"
>"A" "B" "C" "D"
This is the same as the problem of "picking" some (or all) of the
spaces "in between" the letters. So the problem is isomorphic to the
problem of generating all possible subsets of the set {1,...,n-1},
where the string has n letters. For instance, your first string
corresponds to the empty subset of {1,2,3}, the second to {3} (only
the third inter-letter space is chosen), then {2}, {2,3}, {1}, {1,3},
{1,2}, and finally {1,2,3}.
You will probably find it treated under that guise.
--
======================================================================
"It's not denial. I'm just very selective about
what I accept as reality."
--- Calvin ("Calvin and Hobbes" by Bill Watterson)
======================================================================
Arturo Magidin
magidin-at-member-ams-org


|