Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'else:': 0.03; 'ascii': 0.09; 'lookup': 0.09; 'received:209.85.219': 0.09; 'subject:string': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; '23,': 0.16; 'bytearray': 0.16; 'nameerror:': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'to:name:python-list@python.org': 0.22; '>': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'factor': 0.31; 'noted': 0.31; 'extend': 0.32; 'run': 0.32; 'received:209.85': 0.35; 'convert': 0.35; 'subject:lists': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'sequence': 0.36; 'method': 0.36; 'should': 0.36; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'first': 0.61; 'name': 0.63; 'skip:\xe2 10': 0.65; 'n):': 0.84; 'otten': 0.84; '8bit%:33': 0.91 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=Kxi+uHXRbtaMW+dufg/GunzpVe4ZwXJktd8oJkJexh0=; b=errHjL0519QRnUADnY7dA/VIwRZCTc3b430H1Fgi9lkrTBn0Vjvg1jnJosNm7Cg9rJ Xe2jZplgQMiYWrn6vy8xJZ5Z79q2I4iRx5iceoe8uPhgN/GtpuorUJJZMChlRVhOWzNE vn5uT73vsouaS28KBmCGN8FcdVFkOD6AT91XNjb6pn2UNXBDoWetVnsoMs0ohkrcjpC3 bMjY9o4kyK6DgHUVb5J6TpBdZVNsD+2e14dzTyB8eDskD1TWqq6rGTFwfVfIyN7gHj90 H7VXnQPIT/rvS4wNK49v+6OtbVOYjyURrKganLqu7gWGVOdjoOf7I9ecDcxheeLd1mqD QemQ== X-Gm-Message-State: ALoCoQniSpOyM/yNAwguCTSdbGmCHsIZq8QfOKQW0/gHKAv9MliFjfvTu2VAG8uo8C5XGC1AUmq6 X-Received: by 10.182.146.104 with SMTP id tb8mr2319845obb.54.1390506637205; Thu, 23 Jan 2014 11:50:37 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Vincent Davis Date: Thu, 23 Jan 2014 13:50:17 -0600 Subject: Re: generate De Bruijn sequence memory and string vs lists To: "python-list@python.org" Content-Type: multipart/alternative; boundary=f46d04451a392b38c004f0a88e4d X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 72 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390506641 news.xs4all.nl 2953 [2001:888:2000:d::a6]:35200 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64629 --f46d04451a392b38c004f0a88e4d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 =3D k * n * bytearray([0]) > sequence =3D bytearray() > extend =3D sequence.extend # factor out method lookup > def db(t, p): > if t > n: > if n % p =3D=3D 0: > extend(a[1: p+1]) > else: > a[t] =3D a[t - p] > db(t + 1, p) > for j in xrange(a[t - p] + 1, k): > a[t] =3D 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 =E2=80=8B =E2=80=8B sequence to convert to ascii but don't know how to. Vincent Davis --f46d04451a392b38c004f0a88e4d Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

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


I am not really sure what _mapping should be. The cod= e above does not run because
NameError: global name '_mapping' = is not defined
I tried to get the bytearray
=E2=80=8B =E2=80=8Bsequence=C2=A0to convert to ascii but don't know how to.

Vincent Davis

--f46d04451a392b38c004f0a88e4d--