This commit is contained in:
2021-12-10 10:55:53 +01:00
parent 000a72bef5
commit f2ef26fa6e
2 changed files with 104 additions and 0 deletions

42
10/01.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
score=0
while read line; do
chars=( $(sed 's/\(.\)/\1 /g' <<< $line) )
opened_chars=()
for char in ${chars[@]}; do
case $char in
'('|'['|'{'|'<')
opened_chars+=( $char );;
')')
if [ ${opened_chars[-1]} = '(' ]; then
unset 'opened_chars[-1]'
else
score=$((score+3))
break
fi;;
']')
if [ ${opened_chars[-1]} = '[' ]; then
unset 'opened_chars[-1]'
else
score=$((score+57))
break
fi;;
'}')
if [ ${opened_chars[-1]} = '{' ]; then
unset 'opened_chars[-1]'
else
score=$((score+1197))
break
fi;;
'>')
if [ ${opened_chars[-1]} = '<' ]; then
unset 'opened_chars[-1]'
else
score=$((score+25137))
break
fi;;
esac
done
done
echo $score