Skip to content

Instantly share code, notes, and snippets.

@rshk
Created September 10, 2016 16:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rshk/e61bd1fd6cda4acc8a0ec7ccdf21a4a6 to your computer and use it in GitHub Desktop.
Save rshk/e61bd1fd6cda4acc8a0ec7ccdf21a4a6 to your computer and use it in GitHub Desktop.

Dice rolls to bytes

You need ceil(log(2 ** (bytes * 8), 5)) die rolls. This works best if the number of bytes / rolls is fixed / defined in advance.

Take a calculator.

For each die roll:

  • add the result (enter 0 if it was a 6), press =
  • if it's not the last roll: multiply by 5, press =

While the integer part is > 0:

  • If the number (integer part) is even, write a zero, otherwise, write a 1
  • Divide by two

Zero-pad the result

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment