+ day 3, part 2

meow
Dominique Liberda 2022-12-03 02:21:23 -05:00
parent 37782cb7b6
commit 5517832b53
2 changed files with 28 additions and 0 deletions

View File

@ -3,3 +3,7 @@
this one is a biiiit cursed
`cat data | ./meow.sh`
why the *hecc* was this so hard T_T
`cat data | ./nyaa.sh`

24
03/nyaa.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
a=('' a b c d e f g h i j k l m n o p q r s t u v w x y z)
a+=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z)
declare -A meow
for (( i=1; i<${#a[@]}; i++ )); do
meow[${a[$i]}]=$i
done
sum=0
while read l1; do
read l2
read l3
_l1=($(sed 's/./& /g' <<< "$l1"))
for i in ${_l1[@]}; do
if [[ "$l2" == *"$i"* && "$l3" == *"$i"* ]]; then
sum=$((sum+${meow[$i]}))
break
fi
done
done
echo $sum