Sort:  

a better solution:


var runs = 10000;
var total = array();
for(var i = 0; i < options.length; i++){
  for(var j = 0; j < options[i]['chance']; j++){
    total.push(options[i]['Key']);
  }
}
for(var i = 0; i < runs; i++){
  console.log(total[Math.floor(Math.random()*total.length+1)]);
}

omg i just hate programming 😞😞😞. specially turbo c. sorry @rockz i can't help

And what if you do the same thing in java having almost built in fuctions for random numbers picking where you just put your priority e.g

Random().nextInt(int bound) generates a random integer from 0 (inclusive) to bound (exclusive)

If you give the function
private static int getRandomNumberInRange(int min, int max)

private static int getRandomNumberInRange(0, 6) it will generate random numbers between 0 and 6

Getting the random number within a range is not the problem, that is basically what rand(min,max) does.
My problem is to get a number whit a certain chance ;)

so you can set priorities in java with the help of threading

Seit wann ist das hier Stack Overflow? :))

ist es nicht, aber v.l kann es sowas ähnliches werden ;)

thanks for sharing such an helpful and informative post!it will really help the programmer!

Thanks friend @rockz for came back and posting. I am your, follower and reader, like programming but don't know how it works.

Coin Marketplace

STEEM 0.09
TRX 0.30
JST 0.034
BTC 113634.14
ETH 4071.63
USDT 1.00
SBD 0.58