This commit is contained in:
2021-12-02 10:49:38 +01:00
parent b37696aca4
commit 084205f6d7
2 changed files with 38 additions and 0 deletions

18
02/01.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
depth=0
horizontal=0
while read current; do
if [[ "$current" == "down "* ]]; then
current_tmp=${current/down /}
depth=$((depth+current_tmp))
elif [[ "$current" == "up "* ]]; then
current_tmp=${current/up /}
depth=$((depth-current_tmp))
elif [[ "$current" == "forward "* ]]; then
current_tmp=${current/forward /}
horizontal=$((horizontal+current_tmp))
fi
done
echo $((depth*horizontal))