rename repo, subdir for yearly challenges

This commit is contained in:
2021-07-25 11:17:46 +02:00
parent 1806f79e14
commit 4a2318edc9
203 changed files with 212 additions and 1 deletions

21
2020/day03/ex1.bash Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
#
# ex1.bash: Advent2020 game, day 3/game 1.
CMD=${0##*/}
XMOVE=3 # 3 right
declare -i xpos=0 ypos=0 count=0 linelen=0 modpos=0
read -r line # ignore 1st line
while read -r line; do
(( ypos++ ))
(( xpos += XMOVE )) # move right
(( linelen = ${#line} ))
(( modpos = (xpos % linelen) ))
[[ ${line:modpos:1} = \# ]] && ((count++))
done
printf "%s : lines:%d pos=%d found:%d\n" "$CMD" $ypos $xpos $count
exit 0