Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c601849

Browse files
committed
Updated Solutions
1 parent 268fad2 commit c601849

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

Solutions/fortune

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
# A fortune-telling game
44

5-
echo -e "\t\t Welcome to the "
6-
echo -e "\t\t🔮 \033[5mMyStIcAl sPhErE\033[0m 🔮"
5+
echo -e "\t\t Welcome to the "
6+
echo -e "\t\t🔮 \033[5mMYSTICAL SPHERE\033[0m 🔮"
77
echo
88

9-
waitingnumber=$(( 0 + $RANDOM % 3 ))
10-
mysterynumber=$(( 1 + $RANDOM % 10 ))
9+
waitingnumber=$(( 0 + RANDOM % 3 ))
10+
mysterynumber=$(( 1 + RANDOM % 10 ))
1111

1212
declare -a fortunes=(
1313
"You are likely to achieve the outcome you seek."
@@ -30,5 +30,5 @@ case $waitingnumber in
3030
esac
3131

3232
echo
33-
echo ${fortunes[mysterynumber]}
34-
echo
33+
echo "${fortunes[mysterynumber]}"
34+
echo

Solutions/multigame

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
# The game definitions
66
guess() {
7-
local -i mynumber=$(( 1 + $RANDOM % 10 ))
8-
read -p "I'm thinking of a number between 1 and 10. What do you think it is? " theguess
7+
local -i mynumber=$(( 1 + RANDOM % 10 ))
8+
read -rp "I'm thinking of a number between 1 and 10. What do you think it is? " theguess
99
if (( theguess == mynumber )); then
1010
echo "You got it! Great Job!"; echo
1111
else
@@ -16,7 +16,7 @@ guess() {
1616
}
1717

1818
flip() {
19-
local -i mynumber=$(( 1 + $RANDOM % 2 ))
19+
local -i mynumber=$(( 1 + RANDOM % 2 ))
2020
if (( mynumber == 1 )); then
2121
local face="HEADS"
2222
else
@@ -28,8 +28,8 @@ flip() {
2828
}
2929

3030
dice() {
31-
local -i mynumber=$(( 1 + $RANDOM % 6 ))
32-
local -i mynumber2=$(( 1 + $RANDOM % 6 ))
31+
local -i mynumber=$(( 1 + RANDOM % 6 ))
32+
local -i mynumber2=$(( 1 + RANDOM % 6 ))
3333
printf "I rolled two dice and the results are: %s and %s.\n\n" $mynumber $mynumber2
3434
sleep 1
3535
choosegame
@@ -55,4 +55,4 @@ case $1 in
5555
"flip") flip;;
5656
"dice") dice;;
5757
*) choosegame;;
58-
esac
58+
esac

Solutions/sysreport

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ normal="\033[0m"
1111

1212
printf -v logdate "%(%Y-%m-%d)T"
1313

14-
echo -e $bold"Quick system report for "$greentext"$HOSTNAME"$normal
15-
printf "\tKernel Release:\t%s\n" $(uname -r)
16-
printf "\tBash Version:\t%s\n" $BASH_VERSION
17-
printf "\tFree Storage:\t%s\n" $freespace
18-
printf "\tFree Memory:\t%s\n" $freemem
19-
printf "\tFiles in pwd:\t%s\n" $(ls | wc -l)
20-
printf "\tGenerated on:\t%s\n" $logdate
21-
14+
echo -e "$bold Quick system report for $greentext $HOSTNAME$normal"
15+
printf "\tKernel Release:\t%s\n" "$(uname -r)"
16+
printf "\tBash Version:\t%s\n" "$BASH_VERSION"
17+
printf "\tFree Storage:\t%s\n" "$freespace"
18+
printf "\tFree Memory:\t%s\n" "$freemem"
19+
printf "\tFiles in pwd:\t%s\n" "$(ls | wc -l)"
20+
printf "\tGenerated on:\t%s\n" "$logdate"

0 commit comments

Comments
 (0)