[GERMAN] "ziegenproblem"

Dieter Deyke deyke at yahoo.com
Thu Mar 7 14:38:02 EST 2002


stefan antoni <sasoft at gmx.de> writes:

> sorry that i won't be able to explain this in english, i don't know the
> name of this problem in english, and the website which is about this
> problem is also in german.
> 
> i want to write this basic code in python:
> http://www.google.de/search?q=cache:Uugc3CH9SOQC:home.spektracom.de/ellrich/Ziegen.htm+ziegenproblem+basic+programm&hl=de
> 
> i am still going to school, and we talked about this problem in a math
> lesson. since i haven't got a basic-interpreter, i'd like to translate
> this code into python, but i don't understand the code.
> 
> anybody who knows basic and python as well?
> 
> -- 
> stefan antoni

Here you go:

# Das Ziegenproblem, Gero von Randow
# Denken in Wahrscheinlichkeiten, in Python (!)
# Der Moderator darf natürlich weder die Auto-
# noch die gewählte Tür öffnen

import random

print
print "Von 2000 Wechseln waren "
print
for i in range(10):
        r = 0
        f = 0
        for j in range(2000):
                a = random.randrange(1, 4)
                w1 = random.randrange(1, 4)
                while 1:
                        m = random.randrange(1, 4)
                        if m !=a and m != w1: break
                w2 = 6 - m - w1
                if w2 == a: r = r + 1
                if w1 == a: f = f + 1
        print "richtig:", r, "falsch:", f

-- 
Dieter Deyke
mailto:deyke at yahoo.com mailto:deyke at attbi.com
Vs lbh pna ernq guvf, lbh unir jnl gbb zhpu gvzr.



More information about the Python-list mailing list