Solution to scrablle in Bash

This commit is contained in:
2023-05-06 09:15:28 +02:00
parent 81521122ff
commit c4a0a6c693
7 changed files with 963 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env bash
score=0
# converts the word to lowercase
word=$(echo $1 | tr '[:upper:]' '[:lower:]')
for (( i=0; i<${#word}; i++ )); do
letter=${word:i:1}
case $letter in
[aeioulnrst])
score=$((score+1))
;;
[dg])
score=$((score+2))
;;
[bcmp])
score=$((score+3))
;;
[fhvwy])
score=$((score+4))
;;
[k])
score=$((score+5))
;;
[jx])
score=$((score+8))
;;
[qz])
score=$((score+10))
;;
*)
;;
esac
done
echo $score