Code golf challenge: XKCD 936 passwords
sprucebondera at gmail.com
sprucebondera at gmail.com
Tue Oct 8 02:48:01 EDT 2013
On Monday, October 7, 2013 8:45:39 PM UTC-10, spruce... at gmail.com wrote:
> On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote:
>
> > Who's up for some fun? Implement an XKCD-936-compliant password
>
> >
>
> > generator in Python 3, in less code than this:
>
> >
>
> >
>
> >
>
> > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4))
>
> >
>
> >
>
> >
>
> > Second challenge: Use it for generating all your passwords :)
>
> >
>
> >
>
> >
>
> > [1] https://en.wikipedia.org/wiki/Code_golf
>
> >
>
> > [2] http://xkcd.com/936/
>
> >
>
> >
>
> >
>
> > ChrisA
>
>
>
> Well, here's a start:
>
>
>
> import random as r
>
> print(*r.sample(open("/usr/share/dict/words").readlines(),4))
>
>
>
> Shaves off 6 characters.
And if we were actually trying then that filename should just be "/w". Would get rid of another 19 chars.
More information about the Python-list
mailing list