Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Permuting and Combining

Author: Stuart Cracraft

Date: 06:56:32 07/09/04

Go up one level in this thread


On July 08, 2004 at 06:41:48, Tord Romstad wrote:

>On July 07, 2004 at 19:20:09, Stuart Cracraft wrote:
>
>>Hi -- for various test reasons I need to be able to
>>take N strings
>>
>>   A B C D .... N
>>
>>though not literally a total of N... rather any number of strings
>>and produce a list
>>
>><blank>
>>A
>>B
>>:
>>:
>>N
>>A B
>>A C
>>:
>>:
>>A N
>>B C
>>B D
>>:
>>:
>>B N
>>A B C
>>A C D
>>A D E
>>:
>>:
>>....
>>
>>for all possible combinations of the N strings
>>chosen N at a time down to 0 at a time (the null case.)
>
>Hi Stuart,
>
>I am not sure I understand exactly what you want to do.  You ask
>about permutations in the subject line, but from your example above
>it looks like what you really want is just a list of all the subsets
>of the N strings.  But such a list is of course trivial to produce
>(for instance, by looping through binary numbers from 0 to 2^N-1 and
>printing the corresponding subsets), which makes me believe that your
>real problem must be something more complicated.
>
>Could you please give a more precise explanation of your problem?
>
>Tord

Nothing fancy -- just what Dieter solved elegantly. I've replaced my
cumbersome code with Dietercode!

Stuart




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.