Skip to content

Instantly share code, notes, and snippets.

@zv
Last active April 11, 2017 19:51
Show Gist options
  • Save zv/16e5c27308162285d34f682dbc634d49 to your computer and use it in GitHub Desktop.
Save zv/16e5c27308162285d34f682dbc634d49 to your computer and use it in GitHub Desktop.
indentation failure
#! /usr/bin/bash
function repeat { # $1=char $2=number of repetitions
local n # Repeat-print a character.
for (( n=0; n<$2; n++ )); do
echo -n "$1"
done
}
# ...
# ...
# ...
function PrintRods {
local disk rod empty fill sp sequence
repeat " " $spaces1
echo -n "|"
repeat " " $spaces2
echo -n "|"
repeat " " $spaces2
echo "|"
sequence=$(echo $(seq 0 $disks1 | tac))
for disk in $sequence; do
for rod in {1..3}; do
eval empty=$(( $DISKS - (Rod${rod}[$disk] / 2) ))
eval fill=\${Rod${rod}[$disk]}
repeat " " $empty
test $fill -gt 0 && repeat "*" $fill || echo -n "|"
repeat " " $empty
done
echo
done
repeat "=" $basewidth # Print "base" beneath rods.
echo
}
# ...
# ...
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment