Need a function that re-arranges words(!)

Phil Davis davis.phil at comcast.net
Tue Nov 25 23:43:07 EST 2003


You're right - this is a math puzzle. If you represent each word as a single
digit, you can see a pattern as you make lines showing all combinations.
Like this, using 4 "words":

1 2 3 4
1 2 4 3
1 3 2 4
1 3 4 2
1 4 2 3
1 4 3 2

2 1 3 4
2 1 4 3
2 3 1 4
2 3 4 1
2 4 1 3
2 4 3 1

3 1 2 4
... and so on.

So the challenge is, how to express the pattern, or the set of relations
among the "words", mathematically. If anyone can do that, then it's not a
giant leap from there to scripting a "generator".

Phil Davis


> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com
> [mailto:use-revolution-bounces at lists.runrev.com]On Behalf Of
> valetia at mac.com
> Sent: Monday, November 24, 2003 3:32 PM
> To: How to use Revolution
> Subject: Need a function that re-arranges words(!)
>
>
> Hi all,
>
> Help! :) I've been trying to figure this out but it's been a mess, even
> though I think it's probably an easy one.
>
> What I need is rev code that can do this:
>
> Given any phrase, e.g.: "my fat cat"
>
> Spit out all of the following (no need to be in this order):
>
> my fat cat
> my cat fat
> fat my cat
> fat cat my
> cat my fat
> cat fat my
>
> myfat cat
> my fatcat
> myfatcat
>
> mycat fat
> my catfat
> mycatfat
>
> fatmy cat
> fat mycat
> fatmycat
>
> fatcat my
> fat catmy
> fatcatmy
>
> catmy fat
> cat myfat
> catmyfat
>
> catfat my
> cat fatmy
> catfatmy
>
>
> 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! :)
>
> Valetia
>
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list