mirror of https://github.com/01-edu/public.git
3 changed files with 52 additions and 0 deletions
@ -0,0 +1,22 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
# Unofficial Bash Strict Mode |
||||||
|
set -euo pipefail |
||||||
|
IFS=' |
||||||
|
' |
||||||
|
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd) |
||||||
|
|
||||||
|
challenge() { |
||||||
|
submitted=$(bash "$script_dirS"/student/comparator.sh $1 $2) |
||||||
|
expected=$(bash "$script_dirS"/solutions/comparator.sh $1 $2) |
||||||
|
diff <(echo "$submitted") <(echo "$expected") |
||||||
|
} |
||||||
|
for i in $(seq 1 10); do |
||||||
|
n1=$(shuf -i 1-20 -n 1) |
||||||
|
n2=$(shuf -i 1-30 -n 1) |
||||||
|
challenge $n1 $n2 |
||||||
|
done |
||||||
|
|
||||||
|
challenge "0" "0" |
||||||
|
challenge "10" "10" |
||||||
|
challenge "-11" "-11" |
@ -0,0 +1,9 @@ |
|||||||
|
#!/usr/bin/env bash |
||||||
|
|
||||||
|
if [ "$1" -gt "$2" ]; then |
||||||
|
echo "$1 > $2" |
||||||
|
elif [ "$1" -lt "$2" ]; then |
||||||
|
echo "$1 < $2" |
||||||
|
else |
||||||
|
echo "$1 = $2" |
||||||
|
fi |
@ -0,0 +1,21 @@ |
|||||||
|
## comparator |
||||||
|
|
||||||
|
### Instructions |
||||||
|
|
||||||
|
Create a script `comparator.sh` which will verify if the first given argument is bigger, smaller or equal than the second given argument. |
||||||
|
You must print te output like the example in usage. |
||||||
|
|
||||||
|
### Usage |
||||||
|
|
||||||
|
```console |
||||||
|
$ ./comparator.sh 6 14 |
||||||
|
6 < 14 |
||||||
|
$ ./comparator.sh 29 3 |
||||||
|
29 > 3 |
||||||
|
$ ./comparator.sh 12 12 |
||||||
|
12 = 12 |
||||||
|
$ |
||||||
|
``` |
||||||
|
|
||||||
|
> You have to use Man or Google to know more about commands flags, in order to solve this exercise! |
||||||
|
> Google and Man will be your friends! |
Loading…
Reference in new issue