[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: counting using variable length string as base
From:       "Gabriel Genellina" <gagsl-py2 () yahoo ! com ! ar>
Date:       2008-03-31 18:18:50
Message-ID: op.t8v7tocpx6zn5v () a98gizw ! cpe ! telecentro ! net ! ar
[Download RAW message or body]

En Mon, 31 Mar 2008 09:30:00 -0300, Graeme Glass <graemeglass@gmail.com>  
escribió:

> On Mar 27, 11:01 am, Peter Otten <__pete...@web.de> wrote:
>> a b c aa ab ac ba bb bc ca cb cc aaa aab aac aba abb abc aca acb acc  
>> baa bab
>> bac bba bbb bbc bca bcb bcc
>
> Here is a cool solution we came up with during a little interactive
> session at our local meet up.
> (http://www.python.org.za/pugs/cape-town/cape-town)
>
> s = 'abcdef'
> ["".join([s[j] for j in range(len(s)) if x & (1 << j)]) for x in
> range(1,2**len(s)) ]

But it's doesn't generate the right sequence, and a lot of elements are  
missing. For 'abc':
['a', 'b', 'ab', 'c', 'ac', 'bc', 'abc']
It lacks ba, bb, ca, cb, cc, all b??, all c?? - see the sequence quoted  
above.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic