Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!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.025 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'python,': 0.02; 'newbie': 0.05; 'reason,': 0.07; 'suppose': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; 'random': 0.14; 'array.': 0.16; 'cards.': 0.16; 'here).': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; 'mechanism': 0.19; 'result.': 0.19; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'this?': 0.23; 'cheers,': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'array': 0.29; 'direction': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'anyone': 0.31; 'url:python': 0.33; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'done': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'half': 0.37; 'two': 0.37; 'list': 0.37; 'skip:- 10': 0.38; 'pm,': 0.38; 'moving': 0.39; 'url:mail': 0.40; 'how': 0.40; 'hope': 0.61; 'lower': 0.61; 'simple': 0.61; 'cards': 0.65; 'to:addr:gmail.com': 0.65; 'life': 0.66; '26,': 0.68; 'cut': 0.74; 'cards,': 0.84; 'subject:Cutting': 0.84; 'faith': 0.91; 'miracle': 0.93; '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 :cc:content-type; bh=T6dEo/t0yIgCpC14km2q545l7NEJeI+Tyd3HUBCCVMo=; b=ddkBLjqRU9hpZfkhh8P92HgJ8laZ4YMryxWxYXU/XL4rvsxMGSzUAAAP5O7DUV6RJJ EokznjguifYcgE3pIqxQtPxEQspwqtWin5vMgFP5AWvAw14ILo0qfoENe7I7p/zNToHM iBp72eG+6M5sj8OXXJPkrwQLCzQJ8lYnI413Ex7S5/GrGpgB2NLu7rbvdpaScb6fk53M ZFUiAgKoSKTz7iBGhS+oK4ZE92c3LYXa5OPb2j4+tLRPTVTzWbjcVvvP48DoDI0xSZH9 Z/3S03kcGmksXgI8Qf23Uf75sjxB8bau8f2WnCmX3v1AylLyZEci75yyi+PnmktJthjK v50g== MIME-Version: 1.0 X-Received: by 10.182.120.70 with SMTP id la6mr16398038obb.76.1369591551755; Sun, 26 May 2013 11:05:51 -0700 (PDT) In-Reply-To: <4d02f46f-8264-41bf-a254-d1c20469626e@googlegroups.com> References: <4d02f46f-8264-41bf-a254-d1c20469626e@googlegroups.com> Date: Sun, 26 May 2013 23:35:51 +0530 Subject: Re: Cutting a deck of cards From: Kamlesh Mutha To: RVic Content-Type: multipart/alternative; boundary=089e013a0768ee0bc604dda2e181 Cc: python-list@python.org 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: 84 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369591560 news.xs4all.nl 15928 [2001:888:2000:d::a6]:33479 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46090 --089e013a0768ee0bc604dda2e181 Content-Type: text/plain; charset=ISO-8859-1 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 * 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 to the top half of the cards array. > > For some reason, I can't see how this can be done (I know that it must be > a simple line or two in Python, but I am really stuck here). Anyone have > any direction they can give me on this? Thanks, RVic, python newbie > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Faith waiting in the heart of a seed promises a miracle of life which it can not prove! -Ravindranath Tagore --089e013a0768ee0bc604dda2e181 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
I guess, you will have to use list slicing mechanism to ac= hieve the desired result.

Hope this helps,

Cheers,
Kamlesh





On Sun, May 26, 2013 at 11:22 = PM, RVic <rvince99@gmail.com> wrote:
Suppose I have a deck of cards, and I shuffl= e them

import random
cards =3D []
decks =3D 6
cards =3D 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 ra= ndom point (between 1 and 13 * 4 * decks - 1, moving the lower half of that= to the top half of the cards array.

For some reason, I can't see how this can be done (I know that it must = be a simple line or two in Python, but I am really stuck here). Anyone have= any direction they can give me on this? Thanks, RVic, python newbie

--
http://mail.python.org/mailman/listinfo/python-list



-- Faith waiting in the heart of a seed promises a miracle of life which it = can not prove!
-Ravindranath Tagore
--089e013a0768ee0bc604dda2e181--