Created
August 28, 2023 21:05
-
-
Save ZacharyThompson/dbb02f6d0463195b76e9bfa47b2ae63c to your computer and use it in GitHub Desktop.
Test coinflip
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 | |
alias coinflip='echo "H\nT" | shuf -n 1' | |
list=() | |
repeat 1000 do | |
list+=$(coinflip) | |
# list+=$(python3 -c "import random; x=random.randint(0,1); print('H') if x==0 else print('T')") | |
done | |
typeset -A freq | |
for flip in "${list[@]}"; do | |
((freq[$flip]++)) | |
done | |
for flip in "${(@k)freq}"; do | |
echo "$flip: $freq[$flip]" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment