Skip to content

Instantly share code, notes, and snippets.

@lemanschik
Created December 4, 2025 07:22
Show Gist options
  • Select an option

  • Save lemanschik/79cd38230feacc156705711689acaf27 to your computer and use it in GitHub Desktop.

Select an option

Save lemanschik/79cd38230feacc156705711689acaf27 to your computer and use it in GitHub Desktop.
for cop
awk -F"" '{for(i=1;i<=NF;i++)g[NR,i]=$i}END{do{c=0;for(y=1;y<=NR;y++)for(x=1;x<=NF;x++)if(g[y,x]=="@"){n=0;for(j=-1;j<2;j++)for(k=-1;k<2;k++)n+=(g[y+j,x+k]=="@");if(n<5){g[y,x]=".";c++}}t+=c}while(c);print t}' input_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment