Created
November 7, 2022 19:33
-
-
Save roblogic/f90d0b7988ce4a52cb6b785c9f20af33 to your computer and use it in GitHub Desktop.
interim solution for code golf q https://codegolf.stackexchange.com/questions/25416/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
setopt extendedglob | |
s=0 | |
f(){ | |
q=(${(s: :)${1//(#s)d/1d}//[^0-9]/ }) | |
for i ({1..$q[1]})((s+=RANDOM%q[2]+1)) | |
<<<$[s+q[3]] | |
} | |
f d1 | |
f d6 | |
f d1+3 | |
f d20+3 | |
f 2d504+4 | |
f 16d6 | |
f 2d1 | |
f 2d6+2 | |
f d01 | |
f d01+0 | |
f 01d01+01 | |
f 3d20+10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment