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


Groups > comp.lang.python > #56420

Re: Code golf challenge: XKCD 936 passwords

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <random832@fastmail.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'importing': 0.05; 'skip:p 60': 0.07; 'received:internal': 0.09; 'random': 0.14; 'dictionaries': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'portable': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'language': 0.16; 'wrote:': 0.18; 'import': 0.22; 'this?': 0.23; 'subject:Code': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'characters': 0.30; 'file': 0.32; 'monday,': 0.33; 'received:66': 0.35; 'version': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'from:no real name:2**0': 0.61; 'save': 0.62; 'header :Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'different': 0.65; 'skip:p 80': 0.84; '2013,': 0.91; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= SjrvOtqZF//BSHEs9h4jUrTvN0c=; b=nxFiynd4Odnu+dAKRpyUEW7E9wKXceQy sHVYHQ8aYJeifypLw2VdumwsdUVEMzSrm6l3R1KRZUlKVmFVYLDHUVVAe6vF2Yji mTywhzsspl5IUpVq17ix5/4PWkKs8Rn8bUBINB6UOxLFkGs3KjkoU8qG/ETncVst 0DJJfyRHMfw=
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=SjrvOtqZF//BSHEs9h4jUrTvN0c=; b=uh/ +nB/Z+1HB6r7cwqiqPkul5iK8N27LrifLrdV+zNVVv5RsaZRc4yvENTJboQKxjV+ L1upr6lefGzSPU4nHS0nvQ9N7lqYSuFQUS7OrtJzskwJV9gUe6NTSA5xRh/I+KhC rDFLUbjCdyfAHiZzb8TmpkFPGauYCfI6aP+XFNAU=
X-Sasl-Enc Q8VljFvN9JyOWNGiOVQv3Lhx+z/0QgHjiKOY4GWnkHnI 1381247276
From random832@fastmail.us
To python-list@python.org
MIME-Version 1.0
Content-Transfer-Encoding 7bit
Content-Type text/plain
X-Mailer MessagingEngine.com Webmail Interface - ajax-ce174988
In-Reply-To <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com>
References <mailman.828.1381213051.18130.python-list@python.org> <68365e43-498f-4ad2-bac3-6a02938159c7@googlegroups.com>
Subject Re: Code golf challenge: XKCD 936 passwords
Date Tue, 08 Oct 2013 11:47:56 -0400
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.860.1381247279.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1381247279 news.xs4all.nl 15912 [2001:888:2000:d::a6]:54034
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:56420

Show key headers only | View raw


On Tue, Oct 8, 2013, at 2:45, sprucebondera@gmail.com wrote:
> On Monday, October 7, 2013 8:17:21 PM UTC-10, Chris Angelico wrote:
> > print(*__import__("random").sample(open("/usr/share/dict/words").read().split("\n"),4)) # 87
> 
> import random as r
> print(*r.sample(open("/usr/share/dict/words").readlines(),4)) # 80

How about this? My version is also portable to systems with different
file locations, and localizable to different language dictionaries (Some
assembly required).

import sys,random
print(*map(str.strip,random.sample(list(sys.stdin),4))) # 73

Importing random as r doesn't actually save anything, since " as r" is
the same five characters you saved from the one use of it.

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