Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64629 > unrolled thread

Re: generate De Bruijn sequence memory and string vs lists

Started byVincent Davis <vincent@vincentdavis.net>
First post2014-01-23 13:50 -0600
Last post2014-01-23 13:50 -0600
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: generate De Bruijn sequence memory and string vs lists Vincent Davis <vincent@vincentdavis.net> - 2014-01-23 13:50 -0600

#64629 — Re: generate De Bruijn sequence memory and string vs lists

FromVincent Davis <vincent@vincentdavis.net>
Date2014-01-23 13:50 -0600
SubjectRe: generate De Bruijn sequence memory and string vs lists
Message-ID<mailman.5905.1390506641.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Thu, Jan 23, 2014 at 12:02 PM, Peter Otten <__peter__@web.de> wrote:
>
> I just noted that the first Python loop can be eliminated:
>
> def debruijn(k, n):
>     a = k * n * bytearray([0])
>     sequence = bytearray()
>     extend = sequence.extend # factor out method lookup
>     def db(t, p):
>         if t > n:
>             if n % p == 0:
>                 extend(a[1: p+1])
>         else:
>             a[t] = a[t - p]
>             db(t + 1, p)
>             for j in xrange(a[t - p] + 1, k):
>                 a[t] = j
>                 db(t + 1, t)
>     db(1, 1)
>     return sequence.translate(_mapping)


I am not really sure what _mapping should be. The code above does not run
because
NameError: global name '_mapping' is not defined
I tried to get the bytearray
​ ​
sequence to convert to ascii but don't know how to.


Vincent Davis

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web