+ 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
14 odpowiedzi
+ 5
https://code.sololearn.com/cLrT8oxjZN0k/?ref=app
+ 15
Here is my try using Java:
https://code.sololearn.com/cvMPWLpGm0NY/?ref=app
+ 8
https://code.sololearn.com/c9GAfBFf7Ri0/?ref=app
+ 5
Thank you Igor !
My pythonization:
https://code.sololearn.com/c0M7wtJ2Sr74/#py
I added a checking loop
+ 5
Here is my attempt
https://code.sololearn.com/cpBy58zQIyu6/?ref=app
+ 5
It's very simple
https://code.sololearn.com/WAste00703s8/?ref=app
+ 4
https://code.sololearn.com/cxLX4HVq8jw8/?ref=app
+ 3
Not the best way, but solved ;-)
https://code.sololearn.com/cYggRziB4fym/?ref=app
+ 3
A lot shorter:
https://code.sololearn.com/c74yng4gZkLF/?ref=app
+ 3
My code! :)
https://code.sololearn.com/c5Vn2uLo7Bk7/?ref=app
+ 3
uh... here's a oneliner, not sure if I missed something but here
https://code.sololearn.com/c700TVapAgkt/?ref=app
+ 1
My try in C++:
https://code.sololearn.com/cV8lpsPrpXO1/?ref=app