Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ ¹ ² ³ °
 

You are not logged in. Pages: 1 2 #26 20131026 19:23:43
Re: Flaws in logic of solution to a couple of the logic problemsCode:>>> import random >>> def pickbag(): bag = random.randrange(1,4) if bag == 1: return ['W','B'] #return a bag with a white and a black marble elif bag == 2: return ['W', 'W'] else: return ['B', 'B'] >>> def pickmarble(bag): return random.choice(bag) #pick a random marble from the given bag >>> def seeiftheothermarbleiswhite(): bag = pickbag() marble = pickmarble(bag) if marble == 'W': if bag == ['W','W']: return True # First Marble AND second marble white else: return False # Only First Marble White else: return None #First marble is not white, aborting Now, lets do the experiment 1 00 000 times and Mark the cases as Yes when the other marble are white, No when only the First marble is white, Other when the first is not white. Code:>>> Yes = 0 >>> No = 0 >>> Other = 0 >>> for i in xrange(100000): a = seeiftheothermarbleiswhite() if a: Yes += 1 elif a == False: No += 1 else: Other += 1 Now, since we are dealing only with cases when the first marble is white: Code:>>> Yes 33351 >>> No 16533 >>> Other 50116 Code:>>> Yes/float(Yes + No) 0.6685710849170075 Now, that is very close to 2/3 and the rest is experimental error 'And fun? If maths is fun, then getting a tooth extraction is fun. A viral infection is fun. Rabies shots are fun.' 'God exists because Mathematics is consistent, and the devil exists because we cannot prove it' 'Who are you to judge everything?' Alokananda #27 20140122 19:44:12
Re: Flaws in logic of solution to a couple of the logic problems
The flaw in your problem definition is the condition "given that door 2 has a goat", it should be "given Monty opens Door 2" Pages: 1 2 