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


Groups > comp.lang.python > #56524

Re: Code golf challenge: XKCD 936 passwords

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: Code golf challenge: XKCD 936 passwords
Date 2013-10-09 20:29 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-07A5E9.20290009102013@news.panix.com> (permalink)
References <mailman.828.1381213051.18130.python-list@python.org> <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com> <roy-32EAD8.21381208102013@news.panix.com> <CAPTjJmqjBT_Z=8pVGvWcU-5KMvPxunBYs=NwPMwMv1u=9BtVhQ@mail.gmail.com> <mailman.901.1381334893.18130.python-list@python.org>

Show all headers | View raw


In article <mailman.901.1381334893.18130.python-list@python.org>,
 Nick Cash <nick.cash@npcinternational.com> wrote:

> >> # Python-2, sorry
> >> import os
> >> print list(set(open('/usr/share/dict/words')))[os.getpid():][:4]
> 
> > So that steps by your pid? 
> 
> Not really. It seems to rely on list(set(...)) kinda randomizing order... 
> which is definitely not safe without hash randomization.

Exactly.  I *did* preface this with:

>>> If you're willing to accept a sub-optimal random number generator:

[Nick, again]
> But this brings up an interesting concept... if we can assume Python 2.7 with 
> the -R flag, or Python 3.3+, I think we do get true pseudo-randomization out 
> of list(set(...))... which means we can trim some!
> 
> print(list(set(open('/usr/share/dict/words')))[:4])

Excellent!  I didn't know about -R before this, so not only has this 
been fun, it's been educational too!

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Code golf challenge: XKCD 936 passwords Chris Angelico <rosuav@gmail.com> - 2013-10-08 17:17 +1100
  Re: Code golf challenge: XKCD 936 passwords sprucebondera@gmail.com - 2013-10-07 23:45 -0700
    Re: Code golf challenge: XKCD 936 passwords sprucebondera@gmail.com - 2013-10-07 23:48 -0700
      Re: Code golf challenge: XKCD 936 passwords Chris Angelico <rosuav@gmail.com> - 2013-10-08 17:52 +1100
        Re: Code golf challenge: XKCD 936 passwords Roy Smith <roy@panix.com> - 2013-10-08 08:33 -0400
          Re: Code golf challenge: XKCD 936 passwords Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-08 15:36 +0000
            Re: Code golf challenge: XKCD 936 passwords Tim Chase <python.list@tim.thechases.com> - 2013-10-08 11:07 -0500
              Re: Code golf challenge: XKCD 936 passwords Tobiah <toby@tobiah.org> - 2013-10-08 10:38 -0700
      Re: Code golf challenge: XKCD 936 passwords Steve Simmons <square.steve@gmail.com> - 2013-10-08 08:02 +0100
      Re: Code golf challenge: XKCD 936 passwords Chris Angelico <rosuav@gmail.com> - 2013-10-08 18:13 +1100
      Re: Code golf challenge: XKCD 936 passwords Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-08 08:48 +0100
    Re: Code golf challenge: XKCD 936 passwords random832@fastmail.us - 2013-10-08 11:47 -0400
      Re: Code golf challenge: XKCD 936 passwords sprucebondera@gmail.com - 2013-10-08 13:27 -0700
        Re: Code golf challenge: XKCD 936 passwords Chris Angelico <rosuav@gmail.com> - 2013-10-09 07:35 +1100
    Re: Code golf challenge: XKCD 936 passwords Roy Smith <roy@panix.com> - 2013-10-08 21:38 -0400
      Re: Code golf challenge: XKCD 936 passwords Chris Angelico <rosuav@gmail.com> - 2013-10-09 13:10 +1100
        Re: Code golf challenge: XKCD 936 passwords Roy Smith <roy@panix.com> - 2013-10-08 22:52 -0400
      RE: Code golf challenge: XKCD 936 passwords Nick Cash <nick.cash@npcinternational.com> - 2013-10-09 16:07 +0000
        Re: Code golf challenge: XKCD 936 passwords Roy Smith <roy@panix.com> - 2013-10-09 20:29 -0400
  Re: Code golf challenge: XKCD 936 passwords Tobiah <toby@tobiah.org> - 2013-10-08 10:58 -0700

csiph-web