Skip to content

Instantly share code, notes, and snippets.

@sergei-mironov
Created August 24, 2021 20:20
Show Gist options
  • Save sergei-mironov/752ee7290c1e4d6d85668d0a871e7442 to your computer and use it in GitHub Desktop.
Save sergei-mironov/752ee7290c1e4d6d85668d0a871e7442 to your computer and use it in GitHub Desktop.
chess.sh
#!/bin/sh
# https://helloacm.com
H=`stty size | awk '{print $1}'`
W=`stty size | awk '{print $2}'`
for i in $(seq 1 $H)
do
for j in $(seq 1 $W)
do
S=$(((i+j)%2))
if [ $S -eq 0 ]
then
echo -n " " # white
else
echo -n " " # black
fi
done
echo -n "" # black, ensure it exists normally
echo "" # new line
done
echo H $H W $W
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment