16 lines
314 B
Bash
Executable File
16 lines
314 B
Bash
Executable File
#!/bin/bash
|
|
|
|
ct=0 dt=0
|
|
while IFS=$'\n:- ' read lo hi char str; do
|
|
# part 1
|
|
new=${str//$char/}
|
|
diff=$((${#str} - ${#new}))
|
|
((lo <= diff && diff <= hi)) && ((ct++))
|
|
# part 2
|
|
chars=${str:lo-1:1}${str:hi-1:1}
|
|
xor=${chars//$char/}
|
|
((${#xor} == 1)) && ((dt++))
|
|
done
|
|
|
|
printf %s\\n $ct $dt
|