Bending Spoons interview question

Solve a stochastic problem exercise