Skip to content

Instantly share code, notes, and snippets.

@jaqque
Last active April 26, 2020 20:00
Show Gist options
  • Save jaqque/ef5bd921fba29272f3d42a20d34aeea9 to your computer and use it in GitHub Desktop.
Save jaqque/ef5bd921fba29272f3d42a20d34aeea9 to your computer and use it in GitHub Desktop.
#!/bin/zsh
i=0;
count=1000000
tb=0;ty=0;to=0;tg=0
win=0
while (( i<count )); do
b=$(( RANDOM % 7 )); # 1/7 of getting a point
y=$(( RANDOM % 6 )); # 1/6 of getting a point
o=$(( RANDOM % 6 )); # 1/6 of getting a point
g=$(( RANDOM % 6 )); # 1/6 of getting a point
if (( b==0 )); then tb=$(( tb+1 )); fi;
if (( y==0 )); then ty=$(( ty+1 )); fi;
if (( o==0 )); then to=$(( to+1 )); fi;
if (( g==0 )); then tg=$(( tg+1 )); fi;
if (( tb==6 )); then bw=$(( bw+1 )); win=1; fi; #echo -n "b"; fi
if (( ty==7 )); then yw=$(( yw+1 )); win=1; fi; #echo -n "y"; fi
if (( to==7 )); then ow=$(( ow+1 )); win=1; fi; #echo -n "o"; fi
if (( tg==7 )); then gw=$(( gw+1 )); win=1; fi; #echo -n "g"; fi
if (( win==1 )); then
tb=0;
ty=0;
to=0;
tg=0;
win=0;
i=$(( i+1)) ;
fi
done
echo
echo "blue total: $bw"
echo "yellow total: $yw"
echo "yellow total: $ow"
echo "yellow total: $gw"
echo "TOTAL: $(( bw+yw+ow+gw ))"
blue total: 279781
yellow total: 253862
yellow total: 254326
yellow total: 254891
TOTAL: 1042860
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment