Skip to content

Instantly share code, notes, and snippets.

@NerOcrO
Last active August 7, 2021 13:17
Show Gist options
  • Save NerOcrO/afeb6fe3c2c586912a3639fc3f6da4e6 to your computer and use it in GitHub Desktop.
Save NerOcrO/afeb6fe3c2c586912a3639fc3f6da4e6 to your computer and use it in GitHub Desktop.
anglais
#!/bin/bash
clear
bad_color="\e[0;91m"
good_color="\e[0;92m"
info_color="\e[0;96m"
reset_color="\e[0m"
points=0
words=(
"emprunter:to borrow"
"appartenir:to belong"
)
number_of_words=${#words[@]}
for index in $(shuf -e "${!words[@]}");
do
shuffled_words+=("${words[index]}")
done
for ((index = 0; index < number_of_words; index++))
do
french=$(cut -d: -f1 <<< ${shuffled_words[index]})
english=$(cut -d: -f2 <<< ${shuffled_words[index]})
if [ $(($RANDOM % 2)) == 0 ]; then
question=$french
answer=$english
else
question=$english
answer=$french
fi
echo "$question?"
read translation
if [[ $translation == $answer ]]; then
points=$((points + 1))
echo -e "${good_color}Bravo!${reset_color}\n"
else
echo -e "${bad_color}Nop! $answer${reset_color}\n"
fi
done
echo -e "${info_color}Score: $points/$number_of_words${reset_color}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment