@m=((31,(15)x8)x8,(31)x9);\$m[\$c]|=16,!(@a=grep/-?./&!(16+\$|*\$'&\$m[\$c+\$&] ),-18,11,94,-92)?\$c=pop@p:\${\$_=\$a[rand@a];s/-?.//;push@p,\$c;\$m[\$c]&=~(8/ \$_);++\$u-64?\$m[\$c+=\$&]&=~\$_:map\$_&=15,@m,\$c=\$|=1},\$|&&9x3e7,print"\ec", map\$_%9?(\$_-\$c?\$m[\$_]&2?_:\$":o).(\$m[\$_]&8?"|":_):\$/,1..72until\$c>70&\$| ##```## @m=((31,(15)x15)x10,(31)x16);\$m[\$c]|=16,!(@a=grep!(\$m[\$c+\$\$_[0]]&16+\$s*\$ \$_[1]),[-1,8],[1,1],[16,4],[-16,2])?\$c=pop@p:\${(\$i,\$j)=@{\$a[rand@a]};\$m[ \$c]&=~8/\$j;push@p,\$c;\$m[\$c+=\$i]&=~\$j;++\$u-150||map\$_&=15,@m,\$c=\$s=1}, \$s &&select\$x,\$x,\$x,.1*print"\ec",(_)x31,map\$_%16?(\$_-\$c?\$m[\$_]&2?_:\$":o).( \$m[\$_]&8?"|":_):"\$/|",0..160until\$c>158&\$s ##``````## #set up maze - only border visited @m=((31,(15)x15)x10,(31)x16); # until loop starts now #say we've visited current square \$m[\$c]|=16, #find possibilities (on 1st pass (\$s=0) just check visited # on second pass also check the bit is unset for that direction # 4 #8 1 # 2 !(@a=grep !(\$m[\$c+\$\$_[0]]&16+\$s*\$\$_[1]), [-1,8],[1,1],[16,4],[-16,2] )? # if one isn't found then go back \$c=pop@p: # if one is found, then pick it and unset the bits (ie allow access through) \${ (\$i,\$j)=@{\$a[rand@a]}; \$m[\$c]&=~8/\$j; push@p,\$c; \$m[\$c+=\$i]&=~\$j; # and finish if we visit them all (unset visited bit in @m) ++\$u-150||map\$_&=15,@m,\$c=\$s=1 } # and draw (space is here for formatting in wrapped version) \$s&& select\$x,\$x,\$x,.1*print"\ec", (_)x31, map\$_%16?(\$_-\$c?\$m[\$_]&2?_:\$":o).(\$m[\$_]&8?"|":_):"\$/|",0..160 # and redo unless it's the end until\$c>158&\$s ```