dimanche 21 août 2016

Generate a sequence of random 1s and 0s

What is the easiest and quickest way to generate N (let's say 50,000) random unique sequences of length L (let's say 1000) containing 1s and 0s in java? I need this to be a pseudo random generator - Given a certain seed as input, the program should always result in generating the same sequences no matter how many times it's run.

This edit is for the downvoters of this question - random.nextInt() or random.nextDouble() gives me an integer or double value, but I need a sequence of 1s and 0s. If I need a sequence of 1s and 0s corresponding to the random integer generated from random.nextInt() I need to convert that to a binary array? And I need to do this 50,000 times? That's 50,000 * 32 ? I was wondering if there is a faster approach.And that's the purpose of this question.




Aucun commentaire:

Enregistrer un commentaire