Last active
June 1, 2019 08:38
-
-
Save tomaes/cc5d3e4de6a13cdbea0cbd6bc205a051 to your computer and use it in GitHub Desktop.
Shell script test mini game...
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/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