In a survey conducted by the Journal of Applied Logic it was found that out of 200 participants asked to flip a coin they required an average of 358 flips before getting the required result. WTF?! Another study done at Stanford, USA in 1998 determined that 19 out of 20 professional piano players have been playing the wrong tune for years. These two examples are just one example to highlight my point: We live in a universe where we only observe approximate descriptions or incomplete information about how anything works!

It is pretty much impossible to said with absolute certainty what things will happen. When you try to say – with 100% certainty – what will happen, simply you’re lying or kidding yourself because there’s always some random factor involved.

Most people who say something with 100% certainty just trying to please the other people in an attempt to seem knowledgeable. If you say there’s no such thing as God, for example – although that’s what most of us are taught in science class after all – some might ridicule you. But if I go on saying “OMG there IS a God! An intelligent omniscient one too!”, then I will get your approval instead.

## Flip a Coin 3 times

*** Understand this: The Coin does not care about winning or losing. It is only a tool to get your attention on the subject of betting. ***

Flip a coin 100 times and write a program that records how many times it lands on heads.

For 5 times https://flip-a-coin-tosser.com/5-times-flipping/

### Flip a coin generator

I had a programming assignment for my discrete math class: we were given a function that flipped over a coin. For each flip, the function can either return “heads” or “tails”

For example, if this was my first flip and it came up tails…

f(x) = tails x <- 1 else x <- 2

And so, if we ran f(1) , x would be 2 since it was the second flip. If I flipped two heads in a row…

f(x) = heads x <- 1 else x <- 2

My problem is that my program crashes one iteration in 100 because of all these error messages and the like. Any ideas on how to fix?

And then there’s the fact that each iteration takes over 100 iterations of my loop, so it’s kind of slow. Any ideas on how to make it run faster while still being accurate (I don’t mind if I have to define a new function, but any change is going to be an improvement).