22 lines
403 B
Bash
Executable File
22 lines
403 B
Bash
Executable File
#!/bin/bash
|
|
|
|
depth=0
|
|
horizontal=0
|
|
while read current; do
|
|
case "$current" in
|
|
"down "*)
|
|
current_tmp=${current/down /}
|
|
depth=$((depth+current_tmp))
|
|
;;
|
|
"up "*)
|
|
current_tmp=${current/up /}
|
|
depth=$((depth-current_tmp))
|
|
;;
|
|
"forward "*)
|
|
current_tmp=${current/forward /}
|
|
horizontal=$((horizontal+current_tmp))
|
|
esac
|
|
done
|
|
|
|
echo $((depth*horizontal))
|