Home Blog Archives RSS
¶ jay's stupid ass riddle

import sys
import random

if len(sys.argv) < 2: sys.exit(2)

successes = 0
trials = int(sys.argv[1])

for i in range(trials):
    x = random.random()
    y = random.random()
    if ( min(x,y) < 0.5 and \
         max(x,y) - min(x,y) < 0.5 and \
         1 - max(x,y) < 0.5 ): successes += 1

print float(successes) / trials

# python jayriddle.py 1000000

1 / 4

update: Okay, so jay objected to my empirical solution, and then I posted some really arrogant solution that was supposed to be like, "you're a tool. see how easy it is?" but then that was completely wrong and so jay (rightfully) called me a dumbass and then I started thinking about it the right way and realized sonic's solution is about as simple as it gets so I'm just gonna stick with my python script.

Re: jay's stupid ass riddle
Posted 17 years, 6 months ago by Anonymous • @Reply
Albert, gan4 ni3 de diannao...I hate your computer. By the way, just in case you didn't know it, your second solution is incorrect. The way I stated the conditions is the simplest way of describing the problem rigorously. Your conditions are too broad (ie, what if X=0.1 and Y=0.9, then you can't create a triangle), and your probability is wrong too (should be .5*.5 + .5*.5 = 0.5), and somehow those two errors cancel each other to get the correct answer. But it's all because of your stupid computer.
Re: jay's stupid ass riddle
Posted 17 years, 6 months ago by Sonic • @ wwwReply
Hahaha. I like your python script! Jay said 10 minutes though and since I no longer know a "class" from "myass," I figured that I had better just do it by old-school reasoning....and your website still doesn't "remember" me.

Comments disabled until the spammers go away. I hope you comment spammers all die horrible deaths and are forced to delete endless streams of comment spam in your days in purgatory.
• Powered by bBlog