+ 54

CHALLENGE :: Custom Randomizer

Given values and their fixed probability of return. 10 => 60%, 20 => 20%, 30 => 10%, 40 => 5%, 50 => 1%, 60 => 1%, 70 => 1%, 80 => 1%, 90 => 0.5%, 100 => 0.5% So, probability of returning 10 is 60%, probability of returning 20 is 20%, probability of returning 30 is 10% and so on. Task: Generate a random value depending on its fixed probability of return. You can use separate arrays for values and their fixed probabilities or an associative array for both, it doesn't matter. Here's my OOP version. https://code.sololearn.com/wP4NJk0sdIK0/?ref=app

23rd Dec 2017, 5:16 PM
Igor Makarsky
Igor Makarsky - avatar
14 Respostas
+ 5
https://code.sololearn.com/cLrT8oxjZN0k/?ref=app
24th Dec 2017, 10:40 AM
Tim
Tim - avatar
24th Dec 2017, 5:12 AM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
+ 8
https://code.sololearn.com/c9GAfBFf7Ri0/?ref=app
26th Dec 2017, 4:16 AM
Marfik Em
Marfik Em - avatar
+ 5
Thank you Igor ! My pythonization: https://code.sololearn.com/c0M7wtJ2Sr74/#py I added a checking loop
23rd Dec 2017, 10:21 PM
CĂ©pagrave
CĂ©pagrave - avatar
25th Dec 2017, 5:01 AM
Hamid
Hamid - avatar
25th Dec 2017, 3:37 PM
Yauhen Dashkouski
Yauhen Dashkouski - avatar
+ 4
https://code.sololearn.com/cxLX4HVq8jw8/?ref=app
24th Dec 2017, 12:51 PM
DAB
DAB - avatar
+ 3
Not the best way, but solved ;-) https://code.sololearn.com/cYggRziB4fym/?ref=app
23rd Dec 2017, 7:41 PM
Sebastian Keßler
Sebastian Keßler - avatar
23rd Dec 2017, 9:00 PM
Sebastian Keßler
Sebastian Keßler - avatar
25th Dec 2017, 10:05 AM
Javier Monreal Trigo
Javier Monreal Trigo - avatar
+ 3
uh... here's a oneliner, not sure if I missed something but here https://code.sololearn.com/c700TVapAgkt/?ref=app
27th Dec 2017, 6:05 PM
LunarCoffee
LunarCoffee - avatar
2nd Jan 2018, 3:42 PM
Hiroki Masuda
Hiroki Masuda - avatar
25th Dec 2017, 12:49 AM
Yeonung Kim
Yeonung Kim - avatar