Created
January 14, 2022 03:23
-
-
Save jimiyash/6da72f62e7c94dc0d5f96f08ae5ce3fc to your computer and use it in GitHub Desktop.
Spelling test for your kids
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/bash | |
shuffle() { | |
local i tmp size max rand | |
# $RANDOM % (i+1) is biased because of the limited range of $RANDOM | |
# Compensate by using a range which is a multiple of the array size. | |
size=${#array[*]} | |
max=$(( 32768 / size * size )) | |
for ((i=size-1; i>0; i--)); do | |
while (( (rand=$RANDOM) >= max )); do :; done | |
rand=$(( rand % (i+1) )) | |
tmp=${array[i]} array[i]=${array[rand]} array[rand]=$tmp | |
done | |
} | |
declare -a array=( | |
"we" | |
"bee" | |
"need" | |
"queen" | |
"mean" | |
"leaf" | |
"thief" | |
"chief" | |
"pony" | |
"keys" | |
"grow" | |
"toe" | |
"after" | |
"every" | |
"special" | |
) | |
usevoice="alex" | |
pausebetweenwords=7 | |
## shuffle up the words | |
shuffle | |
arraylength=${#array[@]} | |
say -v $usevoice "Spelling Test with " ${arraylength} " words." | |
for (( i=0; i<${arraylength}; i++ )); | |
do | |
if ! (( (i+1) % 6 )); then | |
say -v $usevoice "Child name you are doing great" | |
fi | |
say -v $usevoice "spell ${array[$i]}" | |
sleep $pausebetweenwords | |
done | |
say -v $usevoice "that was the last word. great job!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment