rename repo, subdir for yearly challenges
This commit is contained in:
18
2020/day02/ex1.bash
Executable file
18
2020/day02/ex1.bash
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# ex1.bash: Advent2020 game, day 2/game 1
|
||||
|
||||
CMD=${0##*/}
|
||||
|
||||
declare -i beg end num found=0 nlines=0
|
||||
|
||||
IFS=$':- \t'
|
||||
while read -r beg end char str; do
|
||||
stripped=${str//[^$char]} # keep only specified char
|
||||
((num = ${#stripped})) # occurences of this char
|
||||
((num >= beg && num <= end && found++)) # match ?
|
||||
((nlines++))
|
||||
done
|
||||
printf "${CMD} : lines: %d matched:%d\n" "$nlines" "$found"
|
||||
|
||||
exit 0
|
Reference in New Issue
Block a user