A puzzle for Pythonistas
Magnus Lie Hetland
mlh at furu.idi.ntnu.no
Thu Feb 6 17:13:57 EST 2003
More information about the Python-list mailing list
Thu Feb 6 17:13:57 EST 2003
- Previous message (by thread): A puzzle for Pythonistas
- Next message (by thread): Dumb Q#2 Pycrust
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
In article <slrnb43kc0.fvh.mlh at furu.idi.ntnu.no>, Magnus Lie Hetland wrote: >In article <b68f71a7.0301310459.31539d3c at posting.google.com>, Alan >James Salmoni wrote: [snip] >from numarray import compress >def subsets(seq): > n = len(seq) > for i in xrange(2**n): > cond = [bool(2<<j & i) for j in xrange(n)] Ehm... The bool(...) is quite redundant. Just use the bit manipulation expression on its own :) > yield compress(cond, seq) -- Magnus Lie Hetland "Nothing shocks me. I'm a scientist." http://hetland.org -- Indiana Jones
- Previous message (by thread): A puzzle for Pythonistas
- Next message (by thread): Dumb Q#2 Pycrust
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list