We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#code without comments#!/bin/bashdeclare-Amatrixreaditerationfor((i=1;i<=63;i++));dofor((j=1;j<=100;j++));domatrix[$i,$j]="_"donedonestartRow=64startcolumn=50o=$((2**(5-$iteration)))for((x=16;x>=$o;x/=2));dofor((a=1;a<=x;a++));dostartRow=$((startRow-1))column=$startcolumnn=0while(($column<82));domatrix[$startRow,$(($column))]=1column=$(($column+(4*$x)))donedonebranchleft=$startcolumnbranchright=$branchleftfor((a=1;a<=x;a++));dostartRow=$((startRow-1))n=0while(($branchleft-$a+$n<82&&$branchright+$a+$n<82))domatrix[$startRow,$(($branchleft-$a+$n))]=1matrix[$startRow,$(($branchright+$a+$n))]=1n=$(($n+(4*$x)))donedonestartcolumn=$(($branchleft-$x))donefor((i=1;i<=63;i++));dofor((j=1;j<=100;j++));doecho-ne${matrix[$i,$j]}doneechodone
Cookie support is required to access HackerRank
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 →