Last active
December 4, 2025 08:23
-
-
Save lemanschik/754328148508c4f2a329ce25444f0d28 to your computer and use it in GitHub Desktop.
for cop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mapfile -t G < input.txt | |
| for y in ${!G[@]};do | |
| for((x=0;x<${#G};x++));do | |
| [[ ${G[y]:x:1} < @ ]]||{ | |
| n=0;for i in {0..8};do | |
| (( (Y=y+i/3-1) >= 0 & (X=x+i%3-1) >= 0 )) && \ | |
| [[ ${G[Y]:X:1} == @ ]] && ((n++));done | |
| ((n<5))&&((t++));} | |
| done;done;echo $t |
Author
lemanschik
commented
Dec 4, 2025
Author
part 2
mapfile -t G < input.txt
while :;do D=""
for y in ${!G[@]};do for((x=0;x<${#G};x++));do
[[ ${G[y]:x:1} < @ ]]||{ n=0;for i in {0..8};do
((Y=y+i/3-1,X=x+i%3-1));((Y>=0&&X>=0))&&[[ ${G[Y]:X:1} == @ ]]&&((n++));done
((n<5))&&D+="$y,$x ";}
done;done;[[ -z $D ]]&&break
for p in $D;do y=${p%,*};x=${p#*,};G[y]=${G[y]:0:x}.${G[y]:x+1}
((T++));done;done;echo $T
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment