Re: Cutting a deck of cards

2013-06-12 Thread Chris Angelico
On Mon, May 27, 2013 at 4:16 AM, Carlos Nepomuceno wrote: > list(range(13 * 4 * decks)) == range(13 * 4 * decks) > > ;) Not in Python 3. ChrisA -- http://mail.python.org/mailman/listinfo/python-list

RE: Cutting a deck of cards

2013-06-12 Thread Carlos Nepomuceno
> To: python-list@python.org > From: breamore...@yahoo.co.uk [...] > See this > http://docs.python.org/3/whatsnew/3.3.html#pep-397-python-launcher-for-windows > > -- > If you're using GoogleCrap™ please read this > http://wiki.python.org/moin/GoogleGroupsPyt

RE: Cutting a deck of cards

2013-06-12 Thread Carlos Nepomuceno
> From: usenetm...@solar-empire.de > Subject: Re: Cutting a deck of cards > Date: Sun, 26 May 2013 22:13:55 +0200 > To: python-list@python.org > > Carlos Nepomuceno wrote: >> >>>

Re: Cutting a deck of cards

2013-06-12 Thread Ian Kelly
On Sun, May 26, 2013 at 12:17 PM, RVic wrote: > Ah, brilliant -- yes, this is so much more elegant in Python: > > #now cut the cards > x = random.randrange(2,range(13 * 4 * decks)) > cards = cards[x:]+cards[:x] Or if for some reason you want to do it in place: cards[x:], cards[:x] = cards[:x], c

Re: Cutting a deck of cards

2013-06-12 Thread Ian Kelly
On Sun, May 26, 2013 at 12:16 PM, Carlos Nepomuceno wrote: > list(range(13 * 4 * decks)) == range(13 * 4 * decks) Not in Python 3. -- http://mail.python.org/mailman/listinfo/python-list

Re: Cutting a deck of cards

2013-06-01 Thread Lee Crocker
>> and in fact will probably make it worse depending on how you choose >> the cutpoint. > I'm pretty sure it won't. Otherwise you'd be lowering entropy by doing > a random thing to a random thing. Doing a random thing to a random thing usually *does* lower entropy when the "random" things are a

Re: Cutting a deck of cards

2013-06-01 Thread Joshua Landau
On 31 May 2013 12:56, Lee Crocker wrote: > Why on Earth would you want to? "Cutting" a deck makes no sense in software. > Randomize the deck properly (Google "Fisher-Yates") and start dealing. > Cutting the deck will not make it any more random, True > and in fact will probably make it worse d

Re: Cutting a deck of cards

2013-06-01 Thread Giorgos Tzampanakis
On 2013-05-26, RVic wrote: > Suppose I have a deck of cards, and I shuffle them > > import random > cards = [] > decks = 6 > cards = list(range(13 * 4 * decks)) > random.shuffle(cards) > > So now I have an array of cards. I would like to cut these cards at some > random point (between 1 and 13 * 4

Re: Cutting a deck of cards

2013-05-31 Thread Modulok
> Why on Earth would you want to? "Cutting" a deck makes no sense in > software. Randomize the deck properly (Google "Fisher-Yates") and start > dealing. Cutting the deck will not make it any more random, and in fact > will probably make it worse depending on how you choose the cutpoint. > > The pu

Re: Cutting a deck of cards

2013-05-31 Thread Lee Crocker
Why on Earth would you want to? "Cutting" a deck makes no sense in software. Randomize the deck properly (Google "Fisher-Yates") and start dealing. Cutting the deck will not make it any more random, and in fact will probably make it worse depending on how you choose the cutpoint. The purpose of

Re: Cutting a deck of cards

2013-05-26 Thread Mark Lawrence
On 26/05/2013 23:42, Chris Angelico wrote: On Mon, May 27, 2013 at 8:30 AM, Carlos Nepomuceno wrote: Thanks guys! I've been delaying my dive into Python 3 (because I don't need it for now) but I'd like to run some code just to learn how different it is from Python 2 and even other Python flav

RE: Cutting a deck of cards

2013-05-26 Thread Carlos Nepomuceno
> Date: Mon, 27 May 2013 08:42:56 +1000 > Subject: Re: Cutting a deck of cards > From: ros...@gmail.com [...] > Easy. Just grab the standard installer and hit it. You'll get two > separate directories (or more; I have \Python26,

Re: Cutting a deck of cards

2013-05-26 Thread Chris Angelico
On Mon, May 27, 2013 at 8:30 AM, Carlos Nepomuceno wrote: > Thanks guys! I've been delaying my dive into Python 3 (because I don't need > it for now) but I'd like to run some code just to learn how different it is > from Python 2 and even other Python flavors. > > So, I'd like to know if it's po

RE: Cutting a deck of cards

2013-05-26 Thread Carlos Nepomuceno
> To: python-list@python.org > From: breamore...@yahoo.co.uk [...] > Wrong if you're using Python 3 :( > > -- > If you're using GoogleCrap™ please read this > http://wiki.python.org/moin/GoogleGroupsPython. > > Mark Lawrence Thanks guys! I've been delaying

Re: Cutting a deck of cards

2013-05-26 Thread Mark Lawrence
On 26/05/2013 19:16, Carlos Nepomuceno wrote: Date: Sun, 26 May 2013 10:52:14 -0700 Subject: Cutting a deck of cards From: rvinc...@gmail.com To: python-list@python.org Suppose I have a deck of cards, and I shuffle them import random cards = [] decks

Re: Cutting a deck of cards

2013-05-26 Thread Terry Jan Reedy
On 5/26/2013 3:54 PM, Carlos Nepomuceno wrote: From: usenetm...@solar-empire.de [...] Not in Python3.x decks = 6 list(range(13 * 4 * decks)) == range(13 * 4 * decks) False Adiaŭ Marc What does "list(range(13 * 4 * decks))" returns in Python 3?

Re: Cutting a deck of cards

2013-05-26 Thread Marc Christiansen
Carlos Nepomuceno wrote: > >> From: usenetm...@solar-empire.de > [...] >> Not in Python3.x > decks = 6 > list(range(13 * 4 * decks)) == range(13 * 4 * decks) >> False > > What does "list(range(13 * 4 * decks))" returns in Python 3?

RE: Cutting a deck of cards

2013-05-26 Thread Carlos Nepomuceno
> From: usenetm...@solar-empire.de [...] > Not in Python3.x decks = 6 list(range(13 * 4 * decks)) == range(13 * 4 * decks) > False > > Adiaŭ > Marc What does "list(range(13 * 4 * decks))" returns in Python 3?

Re: Cutting a deck of cards

2013-05-26 Thread Marc Christiansen
Carlos Nepomuceno wrote: > >> Date: Sun, 26 May 2013 10:52:14 -0700 >> Subject: Cutting a deck of cards >> From: rvinc...@gmail.com >> To: python-list@python.org >> >> Suppose I have a deck of cards, and I sh

Re: Cutting a deck of cards

2013-05-26 Thread Roy Smith
In article <4d02f46f-8264-41bf-a254-d1c204696...@googlegroups.com>, RVic wrote: > Suppose I have a deck of cards, and I shuffle them > > import random > cards = [] > decks = 6 > cards = list(range(13 * 4 * decks)) > random.shuffle(cards) > > So now I have an array of cards. I would like to cut

Re: Cutting a deck of cards

2013-05-26 Thread RVic
Ah, brilliant -- yes, this is so much more elegant in Python: #now cut the cards x = random.randrange(2,range(13 * 4 * decks)) cards = cards[x:]+cards[:x] -- http://mail.python.org/mailman/listinfo/python-list

RE: Cutting a deck of cards

2013-05-26 Thread Carlos Nepomuceno
> Date: Sun, 26 May 2013 10:52:14 -0700 > Subject: Cutting a deck of cards > From: rvinc...@gmail.com > To: python-list@python.org > > Suppose I have a deck of cards, and I shuffle them > > import random > cards = [] > decks =

Re: Cutting a deck of cards

2013-05-26 Thread Kamlesh Mutha
I guess, you will have to use list slicing mechanism to achieve the desired result. Hope this helps, Cheers, Kamlesh On Sun, May 26, 2013 at 11:22 PM, RVic wrote: > Suppose I have a deck of cards, and I shuffle them > > import random > cards = [] > decks = 6 > cards = list(range(13 * 4 * d

Re: Cutting a deck of cards

2013-05-26 Thread MRAB
On 26/05/2013 18:52, RVic wrote: Suppose I have a deck of cards, and I shuffle them import random cards = [] decks = 6 cards = list(range(13 * 4 * decks)) random.shuffle(cards) So now I have an array of cards. I would like to cut these cards at some random point (between 1 and 13 * 4 * decks -

Cutting a deck of cards

2013-05-26 Thread RVic
Suppose I have a deck of cards, and I shuffle them import random cards = [] decks = 6 cards = list(range(13 * 4 * decks)) random.shuffle(cards) So now I have an array of cards. I would like to cut these cards at some random point (between 1 and 13 * 4 * decks - 1, moving the lower half of that t