Need a function that re-arranges words(!)
Alex Rice
alex at mindlube.com
Wed Nov 26 00:30:57 EST 2003
On Nov 24, 2003, at 4:32 PM, valetia at mac.com wrote:
>
> Conditions:
>
> 1. The input phrase can be *any* number of words (not just 3).
>
> 2. Each line of the results must contain all the words within (no
> missing
> words).
>
> Any takers? Thanks in advance! :)
This sounds suspiciously like Math homework. Here are some ideas to get
you started.
Counting "my fat cat" and "my cat fat" differently means this is an
ordered selection or permutation.
Combining adjacent words like "myfat cat"... It's still a permutation
problem, but you are significantly expanding the input word set before
doing the real work to enumerate the permutation. Two problems rolled
into one. Trickee!
In my college textbook there are algorithms for "The Next
k-Combination" and "Enumerating All Subsets". The latter involves
representing the set as a binary vector and ticking off the
combinations much like a car odometer. But the former is what I think
you want. For K input words, you want all k-combinations.
I'm drawing a blank as for translating these algorithms into transcript
though. See _Applied Combinatorics with Problem Solving_ by Jackson and
Thoro, Section 4.3
Now Watch someone whip out a 1 liner in Transcript. I will laugh at
myself then :-)
Alex Rice <alex at mindlube.com> | Mindlube Software |
<http://mindlube.com>
what a waste of thumbs that are opposable
to make machines that are disposable -Ani DiFranco
More information about the use-livecode
mailing list