Is java.util.Random really that random? How can I generate 52! (factorial) possible sequences?

前端 未结 9 1962
-上瘾入骨i
-上瘾入骨i 2020-12-22 15:56

I\'ve been using Random (java.util.Random) to shuffle a deck of 52 cards. There are 52! (8.0658175e+67) possibilities. Yet, I\'ve found out that the seed for

9条回答
  •  甜味超标
    2020-12-22 16:29

    If you consider the number as just an array of bits (or bytes) then maybe you could use the (Secure)Random.nextBytes solutions suggested in this Stack Overflow question, and then map the array into a new BigInteger(byte[]).

提交回复
热议问题