day 23 support more inputs
[aoc_eblake.git] / 2015 / advent5.sh
blob608783029bb75912bf4acee57b96967ddb647fe0
1 if [[ $part1 ]]; then
3 nice=0
4 while read word; do
5 case $word in
6 *ab*|*cd*|*pq*|*xy*) ;;
7 *[aeiou]*[aeiou]*[aeiou]*)
8 case $word in
9 *aa*|*bb*|*cc*|*dd*|*ee*|*ff*|*gg*|*hh*|*ii*|*jj*|*kk*|*ll*|*mm*|\
10 *nn*|*oo*|*pp*|*qq*|*rr*|*ss*|*tt*|*uu*|*vv*|*ww*|*xx*|*yy*|*zz*)
11 nice=$((nice+1))
12 esac
13 esac
14 done
15 echo $nice
17 else
19 nice=0
20 patt1=
21 for l1 in {a..z}; do
22 for l2 in {a..z}; do
23 patt1+="|*$l1$l2*$l1$l2*"
24 done
25 done
26 patt2=
27 for l in {a..z}; do
28 patt2+="|*$l?$l*"
29 done
30 while read word; do
31 eval 'case $word in '"${patt1##?}"') ;; *) continue ;; esac'
32 eval 'case $word in '"${patt2##?}"') ;; *) continue ;; esac'
33 nice=$((nice+1))
34 done
35 echo $nice