Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54875
| Path | csiph.com!usenet.pasdenom.info!poup.poupinou.org!news.muarf.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.048 |
| X-Spam-Evidence | '*H*': 0.91; '*S*': 0.00; 'suppose': 0.07; 'list).': 0.09; 'def': 0.12; 'translation': 0.12; 'random': 0.14; '-1,': 0.16; '0):': 0.16; 'cards.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'trying': 0.19; '8bit%:5': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'math': 0.24; 'header:In-Reply-To:1': 0.27; 'sets': 0.30; '(which': 0.31; 'code': 0.31; 'correctly.': 0.31; 'run': 0.32; 'but': 0.35; 'c++': 0.36; 'false': 0.36; 'to:addr:python-list': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; '8bit%:6': 0.40; 'break': 0.61; 'email addr:gmail.com': 0.63; 'card': 0.63; 'cards': 0.65; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'therefore': 0.72; "'while'": 0.84; 'cards,': 0.84; 'dealer,': 0.84; 'repeat.': 0.84; 'reply- to:addr:python.org': 0.84; 'subject:card': 0.93 |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.1 cv=bKAvfpOZ c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=LqG8EI-UCiYA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=4vu7kti2u2wA:10 a=pGLkceISAAAA:8 a=XjE3x-ABb1Lst2-3qVQA:9 a=wPNLvfGTeEIA:10 a=MSl-tDqOz04A:10 |
| X-AUTH | mrabarnett:2500 |
| Date | Fri, 27 Sep 2013 12:27:57 +0100 |
| From | MRAB <python@mrabarnett.plus.com> |
| User-Agent | Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: card dealer |
| References | <0617088e-5aa3-4c5d-b660-22040ee858a1@googlegroups.com> |
| In-Reply-To | <0617088e-5aa3-4c5d-b660-22040ee858a1@googlegroups.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| Reply-To | python-list@python.org |
| 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.377.1380281278.18130.python-list@python.org> (permalink) |
| Lines | 65 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1380281278 news.xs4all.nl 15983 [2001:888:2000:d::a6]:47199 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:54875 |
Show key headers only | View raw
On 27/09/2013 11:24, markotaht@gmail.com wrote:
> from random import *
> from math import floor
>
>
> kaarte_alles = 52
> kaart_tõmmatud = [False for i in range(52)]
>
>
> mast = ["ärtu", "ruutu", "poti", "risti"]
> aste = ["äss", "kaks", "kolm", "neli","viis", "kuus", \
> "seitse", "kaheksa", "üheksa", "kümme", "soldat",\
> "emand", "kuningas"]
>
> def tõmba_kaart():
> global kaarte_alles
> if kaarte_alles == 0:
> print("Segan pakki")
> kaarte_alles = 52
> for i in range(52):
> kaart_tõmmatud[i] = False
> kaarte_alles -= 1
> n = random(kaarte_alles)
> kaart = vali_järgmine_vaba(n)
> m = kaart % 13
> a = kaart / 13
> print(mast[int(a)] + " " + aste[int(m)])
>
> def vali_järgmine_vaba(n):
> i = -1
>
> while(n > 0):
> n -= 1
> i = i + 1
> while kaart_tõmmatud[i]:
> i = i + 1
> kaart_tõmmatud[i] = True
> return i
>
> def random(n):
> return randint(0, n)
>
> while True:
> n = int(input("Mitu kaarti tõmmata(0 et väljuda): "))
> if(n==0):
> break
>
> for i in range(n):
> tõmba_kaart()
>
>
> HI im trying to make a card dealer, but this code doesent work correctly. It deasl cards, but the cards to repeat. when i type in 52 ten i might get 3 the same cards. This is a translation from my c++ code. In c++ it works correctly.
>
Suppose random(...) returns 0.
In 'vali_järgmine_vaba', n == 0, so it won't run anything in the
'while' loop, therefore i == -1, therefore:
kaart_tõmmatud[-1] = True
(which sets the last item in the list).
If random(...) returns 0 again (which is possible),
'vali_järgmine_vaba' will do exactly the same thing.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
card dealer markotaht@gmail.com - 2013-09-27 03:24 -0700
Re: card dealer Dave Angel <davea@davea.name> - 2013-09-27 11:26 +0000
Re: card dealer MRAB <python@mrabarnett.plus.com> - 2013-09-27 12:27 +0100
Re: card dealer Alister <alister.ware@ntlworld.com> - 2013-09-27 11:41 +0000
Re: card dealer Dave Angel <davea@davea.name> - 2013-09-27 12:08 +0000
Re: card dealer Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-27 16:10 +0000
Re: card dealer Dave Angel <davea@davea.name> - 2013-09-27 21:00 +0000
Re: card dealer Ned Batchelder <ned@nedbatchelder.com> - 2013-09-27 17:40 -0400
Re: card dealer Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-28 06:01 +0000
Re: card dealer Ned Batchelder <ned@nedbatchelder.com> - 2013-09-28 06:31 -0400
Re: card dealer Dave Angel <davea@davea.name> - 2013-09-28 12:56 +0000
Re: card dealer Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2013-09-28 16:49 +0200
Re: card dealer Tim Roberts <timr@probo.com> - 2013-09-28 17:04 -0700
csiph-web