Skip to content

Instantly share code, notes, and snippets.

@timhuff timhuff/pi.pyth
Created Mar 14, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.