© Beau Nouvelle 2019
B. NouvelleSimulations in Swift 5https://doi.org/10.1007/978-1-4842-5337-3_3

3. Guessing Game

Beau Nouvelle1 
(1)
Victoria, Australia
 

Here’s a puzzle that features on Randall Munroe’s XKCD blog, and is explained in the Numberphile YouTube video “How to Win a Guessing Game.”

It works like this. Get a friend to pick two different real numbers without telling you what they are. They could roll a dice, generate them with a computer program or just imagine them. Have them write these numbers on two cards and place them facedown on a table. Your friend then chooses a card and flips it over. You now have to guess if the number written on the facedown card is larger or smaller than the one that is faceup.

So what are the odds of you guessing ...

Get Simulations in Swift 5: Design and Implement with Swift Playgrounds now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.