all possible combinations

Steven D'Aprano steve at REMOVETHIScyber.com.au
Wed Jul 13 11:44:26 EDT 2005


On Wed, 13 Jul 2005 10:39:41 -0400, rbt wrote:

>> > What is the most efficient way to do this?
>> 
>> Efficient for who? The user? The programmer? The computer? Efficient use
>> of speed or memory or development time?
> 
> The CPU

Ah, then that's easy. Sit down with pencil and paper, write out all 64
combinations yourself, and then type them into a Python list. Then you can
access any one of those combinations with a single call.

A lookup table is the fastest possible way for the CPU to give you the
answer you want.

[snip]
> My list is not arbitrary. I'm looking for all 'combinations' as I
> originally posted. Order does not matter to me... just all possibilities.

That's good, since you only need combinations of "a", "b" and "c" the
lookup table is quite small and manageable. I was worried that you might
have wanted to apply your function to any set of items.


-- 
Steven.




More information about the Python-list mailing list