Skip to content

Instantly share code, notes, and snippets.

@tomaes tomaes/missingdigit.sh
Last active Jun 1, 2019

Embed
What would you like to do?
Shell script test mini game...
#!/bin/sh
clear
printf "spot the (missing) digit\n"
# rnd(0..9)
r=$(($RANDOM%10))
# unix EPOCH time in seconds
t=$(($(date +%s)))
for i in {0..9}
do
if [ "$i" -ne "$r" ]; then
printf $i
fi
done
# read an int from keyboard
printf "\n?"
declare -i a
read a
printf "\n"
if [ "$a" -eq "$r" ]; then
echo "YES"
else
echo "NO"
fi
printf "TIME:%is\n" $(($(($(date +%s)))-$t))
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.