Skip to content

Instantly share code, notes, and snippets.

@timhuff
Created March 14, 2017 16:35
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 timhuff/9df59630f040966bd95de773ec494461 to your computer and use it in GitHub Desktop.
Save timhuff/9df59630f040966bd95de773ec494461 to your computer and use it in GitHub Desktop.
A.Q@c6csm?-i+OG1+1OG1Z1HH2
Two commands:
A .Q - Parse the input (.Q), assign 1st line (max dice number) to G and 2nd line (number of trials) to H
@c6csm?-i+OG1+1OG1Z1HH2 - The output
The output:
@c6csm?-i+OG1+1OG1Z1HH2
@ c6csm?-i+OG1+1OG1Z1HH 2 - Take the square root of the middle chunk
c 6 csm?-i+OG1+1OG1Z1HH - Divide 6 by the 3rd chunk
c sm?-i+OG1+1OG1Z1H H - Divide the middle chunk by H (the number of trials)
s m?-i+OG1+1OG1Z1H - Get the sum of the list generated by the 2nd chunk
m ?-i+OG1+1OG1Z1 H - Create list of H numbers, as described by middle chunk
? -i+OG1+1OG1 Z 1 - if 2nd chunk is 0, make the value 1 - else make it zero
- i+OG1+1OG 1 - the 2nd chunk minus 1
i +OG1 +1OG - GCD of the 2nd and 3rd chunks
+ OG 1 - 2nd chunk plus 1
O G - random number from 0 to G-1, inclusive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment