11/25/2020:Shuffling a list of any size
source code
11/02/2020: With HPB's remix page using solidity it is simple to generate a truly random number with the built-in variable block.random which is a bytes32 object which returns a 64-digit hexidecimal value(Make sure you select compiler 0.57!). However only one random number is generated per block, what if you needed to generate more than one random number in a function? Well I thought about it for a while and then realized that if the digits of the bytes object are all random, then each subset of the digits are also random. Which means that they can be split up! But we don't want to split them up too much because depending on the range of values wanting to be generated, it could introduce significant modulo bias. But splitting up into 8 seperate 8 hexidecimal digits would still leave 2^32 possible values for each(0 - 4,294,967,295), it would still leave small modulo bias but this function does a simple checks to remove them completely using rejection sampling, but you may not end up with the number of random numbers that you had requested. Any thoughts on this? Maybe there is a better way, let us know in the HPB community Dev channel!
Join the official HPB telegram for real-time information and updates.
Follow us on Twitter