Tech Interview

A site for technical interview questions, brain teasers, puzzles, quizzles (whatever the heck those are) and other things that make you think!

    • 13 Apr 2010

      Flipping Coins

      Posted at 11:03 am by Admin, on April 13, 2010

      Someone walks into your room and dumps a huge bag of quarters all over the floor. They spread them out so no quarters are on top of any other quarters. a robot then comes into the room and is programmed such that if it sees a head, it flips it to tails. If it sees a tail, it throws it in the air. the robot moves around randomly forever. Will there be a convergence in distribution of heads vs. tails?


      Soultion

      Hmmm. I made a little math trick out of it. If the ‘bot finds a head, it flips. If the bot finds a tail, there’s a fifty percent chance this will become a head, as well.

      (P_h = #heads/#coins, P_t = #tails/#coins)

      So, delta h = -P_h + .5 P_t

      = -(1 – P_t) + .5 P_t

      = 1.5 P_t -1

      Which is zero when P_t is 2/3. It’s important to remember that a flip to a tail results in no change to the number of tails — this threw me off for a second.

      0 Comments
      Posted in regular

Proudly powered by WordPress.

Theme: Minipress by Obox Themes.