- Регистрация
- 15.05.2017
- Сообщения
- 436
- Благодарностей
- 104
- Баллы
- 43
Probably a simple question, but sometimes there is need to do something random by percentages, currently I am using such a solution, but I am sure there is something more elegant.
Here we generate a random number from 1 to 10, and only when it's 10 we pause for a longer time (10%), and if the number is 8 or 9 we pause for 5 sec. (20% chance).
Please share how you do this, thank you!
Here we generate a random number from 1 to 10, and only when it's 10 we pause for a longer time (10%), and if the number is 8 or 9 we pause for 5 sec. (20% chance).
Please share how you do this, thank you!