2 ms·
I made this: https://pastebin.com/kQhKexEd https://pastebin.com/kQhKexEd in 5 minutes. It is however slightly off with the random distribution since I am only d
by bjoli 8y ago
I made this: https://pastebin.com/kQhKexEd https://pastebin.com/kQhKexEd in 5 minutes. It is however slightly off with the random distribution since I am only doing a simple remainder.
- andreareina 8y ago(let ((byte (remainder (get-u8 urandom) size))) is skewed if size isn't a power of 2. What you should do is mod by the next-largest power of 2 (e.g. if size is 82, mod by 128). Then if the result is in-range use it, otherwise discard and reroll.
- bjoli 8y agoI just edited the comment before I saw your answer. I realised my mistake and wanted to sink through the earth. Everyone has brain farts, I guess. What I ended up doing was limiting the charset size to 256 a maximum of characters, and then discarding any value that is larger than the current charset.