Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

percentages

Name: Anonymous 2011-11-09 20:15

Help /prog/ I suck at maths.

I have a range of countries with associated percentages.

How can I base an if condition around that percentage so if I have Switzerland at 44%, there is a 44% chance of evaluating to Switzerland.

Name: Anonymous 2011-11-09 20:20

Create a 100 element integer array, fill each element with a country id according to its percentage.

Then choose a random number < 100, and that's your country.

For more precision increase the array length as necessary (10000 elements won't be a problem at all and gives you two decimal places).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List