master
Dominika 2021-12-02 23:06:25 +01:00
commit 57da860ae4
2 changed files with 41 additions and 0 deletions

16
1_1.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
last=0
max=0
inc=0
while read line; do
if [[ $line -gt $max ]]; then
max=$line
inc=$((inc+1))
elif [[ $line -gt $last ]]; then
inc=$((inc+1))
fi
last=$line
done
echo $((inc-1))

25
1_2.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
inc=0
max=0
arr=()
while read line; do
arr+=("$line")
done
for ((i=0; i<${#arr[@]}; i++)); do
if [[ "${arr[$((i+3))]}" ]]; then
val=$((${arr[$i]}+${arr[$((i+1))]}+${arr[$((i+2))]}))
else
break
fi
if [[ $val -gt $max ]]; then
max=$val
inc=$((inc+1))
elif [[ $val -gt $last ]]; then
inc=$((inc+1))
fi
last=$val
done
echo $inc