All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Probability
Coin Flip Conundrum (Posted on 2024-11-12) Difficulty: 3 of 5
Joe flips a coin 20 times, find the probability that he never gets 2 consecutive heads or 3 consecutive tails.

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 1 of 2
clearvars,clc
global series goodCt
series=''; goodCt=0;
addon;
goodCt
2^20
goodCt/2^20
2^20 / goodCt


function addon()
global series goodCt
  for new='01'
    saveseries=series;
    if length(series)<(new=='0')+1
      series=[series,new];
    else
      if new=='1' &&  series(end)=='1'
        continue
      end
      if new=='0' &&  isequal(series(end-1:end),'00')
        continue
      end
      series(end+1)=new;
    end
    if length(series)==20
      goodCt=goodCt+1;
    else
      addon;
    end
    series=saveseries;
  end
end

finds

goodCt =
   465
ans =
     1048576
ans =
      0.000443458557128906
ans =
          2255.00215053763

indicating that 465 out of the 2^20 = 1,048,576 possible sequences fit the criteria for a probability of   0.000443458557128906, or about 1 in 2255.


  Posted by Charlie on 2024-11-12 09:53:46
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information