Skip to content

Instantly share code, notes, and snippets.

@ZacharyThompson
Created August 28, 2023 21:05
Show Gist options
  • Save ZacharyThompson/dbb02f6d0463195b76e9bfa47b2ae63c to your computer and use it in GitHub Desktop.
Save ZacharyThompson/dbb02f6d0463195b76e9bfa47b2ae63c to your computer and use it in GitHub Desktop.
Test coinflip
#!/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