Draft

Will you get head?

Description:

Introduction

As you are taking a stroll through the newly opened carnival in your city, you are approached by a man dressed in a magician suit.

Welcome, good sir! Care to play a game?

Just guess our act right and ...

Sorry, wrong site.

Observe me as I throw this very special coin into the air.

After saying this, the man proceeds to flip the coin total times, landing heads heads out of those.

I've given you this information; now I ask you: Are you willing to bet bet dolars of your money for a chance to win the grand total of prize dolars, if the next throw lands heads again?

Knowing that the coin may be biased. You must make a decision as to whether you will take this bet or not.

Task

Given that a possibly biased coin landed heads heads out of total throws, determine whether you should take a bet of bet dolars for a chance of getting prize dolars back.

- heads: [0, 1000] (integer)
- total: [0, 1000] (integer)

Notes

  • A bet should be taken if and only if the expected value of the bet is greater than the prize.

  • Consider that, without any information, all the possible biases of the coin are equally likely. In other words, the coin is initially presumed to be fair.

  • heads and total will always be non negative integers with total being greater or equal to heads

  • bet and prize will always be real numbers. A negative bet should be interpreted as receiving money to play the bet, while a negative prize should be interpreted as paying money upon winning. Using expected value, still works in these cases.

Examples

prediction(0, 0, 1, 2) -> False
prediction(3, 3, 10, 14) -> True
prediction(0, 3, 1, 6) -> True
prediction(10, 12, 1, 1.2) -> False
prediction(100, 100, 1, .9) -> False
prediction(0, 0, -1, -1.99) -> True
prediction(0, 1_000, -1, 0) -> True
prediction(1_000, 1_000, 0, -.9) -> False
Mathematics
Probability

More By Author:

Check out these other kata created by Yushi.py

Stats:

CreatedOct 22, 2023
Warriors Trained100
Total Skips27
Total Code Submissions135
Total Times Completed16
Python Completions16
Total Stars1
% of votes with a positive feedback rating72% of 9
Total "Very Satisfied" Votes5
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes1
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Yushi.py Avatar
Ad