You are viewing a single comment's thread. Return to all comments →
Kind of sad this is not a valid answer but i get it, it is a really inefficient solution
rows=63 cols=100 max_it=5 first_y_size=16 declare -A fractal_positions function fractals { local it=$1 local row=$2 local col=$3 local y_size=$4 if (( $it > $max_it)) || (( $it > $N )); then return fi fractals $(( $it + 1 )) $(( $row - $y_size * 2 )) $(( $col - $y_size )) $(( $y_size / 2 )) fractals $(( $it + 1 )) $(( $row - $y_size * 2 )) $(( $col + $y_size )) $(( $y_size / 2 )) for (( i = $row; i > $row - $y_size; i--)); do fractal_positions[$(printf "%d|%d" $((i-1)) $col)]=1 done local tmp=1 for (( i = $row - $y_size; i > $row - $y_size * 2; i--)); do fractal_positions[$(printf "%d|%d" $((i-1)) $(( $col - $tmp )))]=1 fractal_positions[$(printf "%d|%d" $((i-1)) $(( $col + $tmp )))]=1 tmp=$(($tmp+1)) done } read -r N fractals 1 $rows $(( $cols / 2 )) $first_y_size for ((i=0; i < $rows; i++)); do for ((j=0; j < $cols; j++)); do if ((fractal_positions[$(printf "%d|%d" $i $j)] == 1)); then printf "1" else printf "_" fi done printf "\n" done
Seems like cookies are disabled on this browser, please enable them to open this website
Functions and Fractals - Recursive Trees - Bash!
You are viewing a single comment's thread. Return to all comments →
Kind of sad this is not a valid answer but i get it, it is a really inefficient solution