Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [[ $# < 2 ]]; then
- echo "Wrong args amount"
- exit 1
- fi
- if [[ $2 < 1 ]]; then
- echo "S lower than 1"
- exit 1
- fi
- if [[ $2 > $1 ]]; then
- echo "S greater than N"
- exit 1
- fi
- counter=0
- n=$1
- while [ $licznik -lt $n ]
- do
- tab[$licznik]=_
- let "counter++"
- done
- s=$2
- while [ $s -gt 0 ]
- do
- a=$((RANDOM % ($1-0+1) + 0))
- if [[ ${tab[$a]} == _ ]]; then
- tab[$a]="X"
- let 's--'
- fi
- done
- hits=0
- moves=0
- while [ $hits -lt $2 ]
- do
- echo "Your move"
- read choice
- if [[ ${tab[$choice]} == "X" ]]; then
- echo "HIT"
- let 'hits++'
- else
- echo "Miss"
- fi
- let 'moves++'
- done
- echo "Result: "$2"/"$moves
Add Comment
Please, Sign In to add comment