Problem 44286. Compute average gain for some bets.

Given a vector containg the odds of some events in decimal format (e.g., odds=[1.3 2.5 1.5] ) and a vector of the same dimensions containing the amount of dollars that you are betting for each of those (e.g., bets=[100 10 80] ), the function avg_gain(odds,bets) should return the average of the gain for each possible outcome. The average is a simple average and should not weight the events by their actual probability. Moreover it needs to be rounded to the second decimal digit.

Example: odds= [1.1] bets= [100]

there are only two possible outcomes in this simple case:

  1. Item one I win the bet: I gain 100*1.1 -100 dollars= +10 dollars
  2. Item two I lose the bet: I just lose the bet of 100 dollars = -100 dollars.

So I need to perform an average of -100 and 10 that is -45.

Disclaimer: a positive average does not mean that betting is a good idea, since we are only performing a simple average, ignoring the probabilities of the different events. I want in no way encourage betting since it is risky and sometimes addictive. It's just a simple Cody problem, take it for what it really is.

Solution Stats

40.0% Correct | 60.0% Incorrect
Last Solution submitted on Mar 08, 2020

Problem Comments