Skip to content

Instantly share code, notes, and snippets.

@alibitek
Created September 2, 2016 17:20
Show Gist options
  • Save alibitek/d994e05a382892f2cba0060499f2748e to your computer and use it in GitHub Desktop.
Save alibitek/d994e05a382892f2cba0060499f2748e to your computer and use it in GitHub Desktop.
read -r iterations
readonly iterations
declare -A arr
rows=63
cols=100
for ((i = 1; i <= rows; i++)); do
for ((j = 1; j <= cols; j++)); do
arr[$i,$j]=_
done
done
function gen() {
local x=$1
local y=$2
local d=$3
local h=$4
local hh=$((h/2))
if [[ $d -eq 0 ]]; then
return 1
fi
for ((i = 1; i <= hh; i++)); do
arr[$(($y+$i)),$x]="1"
arr[$(($y+$hh+$i)),$(($x-$i))]="1"
arr[$(($y+$hh+$i)),$(($x+$i))]="1"
done
gen $((x-hh)) $((y+h)) $((d-1)) $hh
gen $((x+hh)) $((y+h)) $((d-1)) $hh
}
gen 50 0 $iterations 32
for ((i = rows; i >= 0; i--)); do
for ((j = 1; j <= cols; j++)); do
echo -n "${arr[$i,$j]}"
done
echo -e
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment