Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; 'url:au': 0.05; "subject:' ": 0.07; 'subject:help': 0.08; 'ascii': 0.09; 'lookup': 0.09; 'oh,': 0.09; 'shame': 0.09; 'so?': 0.09; 'subject:using': 0.09; 'posted': 0.15; '1:09': 0.16; ':-p': 0.16; 'add,': 0.16; 'collections': 0.16; 'dice': 0.16; 'digits.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'multiples': 0.16; 'ops': 0.16; 'subject: \n ': 0.16; 'subtract': 0.16; 'subject:python': 0.16; ':-)': 0.16; 'wrote:': 0.18; '(the': 0.22; 'import': 0.22; 'stick': 0.24; 'tend': 0.24; 'decide': 0.24; 'header:In-Reply-To:1': 0.27; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; 'are.': 0.31; "company's": 0.31; "d'aprano": 0.31; 'probability': 0.31; 'steven': 0.31; 'anyone': 0.31; 'probably': 0.32; 'option': 0.32; 'regular': 0.32; 'another': 0.32; 'entirely': 0.33; 'common': 0.35; 'possible.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'there': 0.35; 'ones,': 0.36; "didn't": 0.36; 'two': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; '12,': 0.39; 'stock': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'even': 0.60; 'easy': 0.60; 'above,': 0.60; 'most': 0.60; "you're": 0.61; 'pick': 0.64; '(that': 0.65; 'here': 0.66; '26,': 0.68; 'therefore': 0.72; 'hand': 0.80; '(add,': 0.84; 'cost,': 0.84; 'divide': 0.84; 'each,': 0.84; 'maths': 0.84; 'stock.': 0.84; 'thing,': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=k9z1/QhwufFrInJTuBfs0+owJsa+Zg0eVpE6HjlLsdw=; b=ASG6zPOlSNFU9qFxlhUdu6OHGU7VX1f3h/H9CtdoBdqi4cMgSNJ8ZmDoBRctouVhpW j1MGEPcqaD5QxMM10eiRm4Ynjl4WM85P2vvKQsRHSNQc7+j/eMGU3afme1FeLK5CYbBu wLfwLh0CwUOY+xRICQIGOwsuGqFJlEoQV4jVzNf7ngSdED8CRvtE9d3nwpvi3eVBa2Ol M3MFrdGuYs9E3n7LuFVzkTEEjbZOnMF0I/W5KqnsEigFgZgyBrzcxSiys55aLUjPueBB aqWJJDI/5Zci4IRfzSoxU6bh3oQpZtO67uMSXRn6m8yRSAeA+wSM+pDgWeM+qMzDJO1r xmQw== MIME-Version: 1.0 X-Received: by 10.220.111.133 with SMTP id s5mr1546830vcp.63.1369540949465; Sat, 25 May 2013 21:02:29 -0700 (PDT) In-Reply-To: <51a17cff$0$30002$c3e8da3$5496439d@news.astraweb.com> References: <78192328-b31b-49d9-9cd6-ec742c092a29@googlegroups.com> <39ac7437-857e-483f-998c-8162c1039933@googlegroups.com> <51a052d1$0$6599$c3e8da3$5496439d@news.astraweb.com> <74e33270-a79a-4878-a400-8a6cda6637b2@googlegroups.com> <51a0ca91$0$30002$c3e8da3$5496439d@news.astraweb.com> <51a17cff$0$30002$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 26 May 2013 14:02:29 +1000 Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369540952 news.xs4all.nl 15886 [2001:888:2000:d::a6]:47897 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46038 On Sun, May 26, 2013 at 1:09 PM, Steven D'Aprano wrote: > You're right, all my dice are eight-sided and complex: > > 1+0i > 1+1i > 1-1i > -1+0i > -1+1i > -1-1i > > > :-) Now THAT is a dice of win! >> Now, I have here with me >> a set used for maths drill (to be entirely accurate, what I have here is >> the company's stock of them, so there are multiples of each of these - >> anyone need to buy dice?) > > Are you serious? What's the cost, posted to Melbourne? $1 each, postage probably $5 for any number. Or there may even be option to pick up / hand deliver, depending on where in Melb you are. http://www.kepl.com.au/ - company's winding down, but we still have stock. > Oh, you mean =F7 (division sign)! Why didn't you say so? :-P I tend to stick to ASCII in these posts. :) > And another thing, shame on you, you mean =D7 not x. It's easy to find to= o: > > py> from unicodedata import lookup > py> print(lookup("MULTIPLICATION SIGN")) > =D7 I'm aware of that, but see above, I stick to ASCII where possible. The faces would be better represented with some of the other digits (the bolded ones, perhaps), but I used the ASCII digits. :) >> Plus, if you roll 2d6 (that is, two >> regular six-sided dice and add them up), 7 is statistically the most >> likely number to come up with. Therefore it IS random. > > Yes, but if you subtract them the most common is 0, if you multiply the > most common are 6 or 12, and if you divide the most common is 1. If you > decide on the operation randomly, using the +-=D7=F7+ die above (ignoring > wildcards), the most common result is 6. The probability of getting a 7 > is just 1/15. > > from collections import Counter > from operator import add, sub, mul, truediv as div > ops =3D (add, sub, mul, div, add) > Counter(op(i, j) for op in ops for i in range(1, 7) for j in range(1, 7)) LOL! I never thought to go THAT far into the analysis..... Nice one! ChrisA