Thread: hard problem

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    88
    Rep Power
    10

    hard problem


    Ok, can someone help me write a script to simulate the following?
    you have n number of kids in a room with index cards. they all fill out the cards with their names and info and pass them in to the teacher. then the teacher shuffles and passes them back. what is the probability that noone gets their own card back. come up with a formula that you can use where you can calculate the probability given that n is ANY NUMBER. so like, whats this probability when there are 2 kids (1/2), or what about 3? 4? 5? 10? 100? 1000? 9 billion?
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,626
    Rep Power
    4247
    Please Read This First
    1. Hard Problem is not a good subject title.
    2. We're not exactly a free homework agency. People tend to help here, only if you show that you've done some work.
    3. The equation to determine this has nothing to do with Python and everything to do with probability theory. I know how to derive it, but I'm not about to do your homework for you. Ask one of your classmates or a mathematics major for help. A good gambler may be another source of help -- a lot of them are rather well up on their probability theory fundamentals. Once you have the right formula, implementing it in python or any other language is a piece of cake.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Location
    Houston, TX
    Posts
    383
    Rep Power
    13
    Originally Posted by Scorpions4ever
    Please Read This First
    1. Hard Problem is not a good subject title.
    2. We're not exactly a free homework agency. People tend to help here, only if you show that you've done some work.
    3. The equation to determine this has nothing to do with Python and everything to do with probability theory. I know how to derive it, but I'm not about to do your homework for you. Ask one of your classmates or a mathematics major for help. A good gambler may be another source of help -- a lot of them are rather well up on their probability theory fundamentals. Once you have the right formula, implementing it in python or any other language is a piece of cake.
    ::applause::

    The answer is 4.
    Debian - because life's too short for worrying.
    Best. (Python.) IRC bot. ever.

IMN logo majestic logo threadwatch logo seochat tools logo