Re: Combinatorics question
- From: Mensanator <mensanator@xxxxxxx>
- Date: Sun, 6 Apr 2008 08:08:33 -0700 (PDT)
On Apr 6, 12:37 am, Mariano Suárez-Alvarez
<mariano.suarezalva...@xxxxxxxxx> wrote:
On 5 abr, 21:13, Mensanator <mensana...@xxxxxxx> wrote:
On Apr 5, 6:46�pm, Ketakop...@xxxxxxxxx wrote:
Thanks a lot for the help so far. It sure has been of much help. The
only thing is, that I'm having a bit of hard time understanding the
codes ;)
Whose? If it's MSA's code, that's understandable as
it's incorrect. Althought he does, in fact, generate
the correct count of C(10,4), all the numbers generated
end in '00', his minimum number being 0000111100
instead of the correct 0000001111. And some of his
numbers have 12 bits. You'll find in gerneral that
generating wrong answers asymtotically faster isn't
better.
Ah. What I wrote and tested was:
def subsets(n, i, min = 1):
if i == 0:
yield []
elif n - min + 1 >= i:
for m in xrange(min, n + 1):
for s in subsets(n, i - 1, m + 1):
yield [m] + s
which enumerates the actual subsets and
messed up in trying to come up with
def subsets(n, i, min = 1):
if i == 0:
yield 0
elif n - min + 1 >= i:
for m in xrange(min, n + 1):
for s in subsets(n, i - 1, m + 1):
yield (1 << (m - 1)) + s
which instead enumerates numbers coding the
subsets. That's what one gets from not testing.
You are surely not contesting the claim
about efficiency, of course ;-)
No, of course not. Doesn't solve the OP's problem though.
Do you have an asymptotically faster way of doing the
Hamming Distance check?
-- m
.
- Follow-Ups:
- Re: Combinatorics question
- From: Mariano Suárez-Alvarez
- Re: Combinatorics question
- References:
- Combinatorics question
- From: Ketakopter
- Re: Combinatorics question
- From: Mensanator
- Re: Combinatorics question
- From: Mariano Suárez-Alvarez
- Re: Combinatorics question
- From: Ketakopter
- Re: Combinatorics question
- From: Mensanator
- Re: Combinatorics question
- From: Mariano Suárez-Alvarez
- Combinatorics question
- Prev by Date: Re: Combinatorics question
- Next by Date: Re: (finite)galois field
- Previous by thread: Re: Combinatorics question
- Next by thread: Re: Combinatorics question
- Index(es):
Relevant Pages
|