Task
Produce a graphical or ASCII-art representation of a Sierpinski carpet of order   N.



For example, the Sierpinski carpet of order   3   should look like this:

###########################
# ## ## ## ## ## ## ## ## #
###########################
###   ######   ######   ###
# #   # ## #   # ## #   # #
###   ######   ######   ###
###########################
# ## ## ## ## ## ## ## ## #
###########################
#########         #########
# ## ## #         # ## ## #
#########         #########
###   ###         ###   ###
# #   # #         # #   # #
###   ###         ###   ###
#########         #########
# ## ## #         # ## ## #
#########         #########
###########################
# ## ## ## ## ## ## ## ## #
###########################
###   ######   ######   ###
# #   # ## #   # ## #   # #
###   ######   ######   ###
###########################
# ## ## ## ## ## ## ## ## #
###########################

The use of the   #   character is not rigidly required for ASCII art.

The important requirement is the placement of whitespace and non-whitespace characters.



Related task

   Sierpinski triangle


sub sp$(n)
	local i, s$
 
	for i = 1 to n
		s$ = s$ + " "
	next i
	return s$
end sub
 
sub replace$(s$, cf$, cr$)
	local i, p
 
	do
		i = instr(s$, cf$, p)
		if not i break
		mid$(s$, i, 1) = cr$
		p = i
	loop
	return s$
end sub
 
sub foreach$(carpet$, p$, m)
	local n, i, t$(1)
 
	n = token(carpet$, t$(), ",")
 
	for i = 1 to n
		switch(m)
		case 0:	p$ = p$ + "," + t$(i) + t$(i) + t$(i) : break
		case 1: p$ = p$ + "," + t$(i) + sp$(len(t$(i))) + t$(i) : break
		default: error "Method not found!" : break
		end switch
	next i
	return p$
end sub
 
sub sierpinskiCarpet$(n)
    local carpet$, next$, i
 
    carpet$ = "@"
    for i = 1 to n
        next$ = foreach$(carpet$, "")
        next$ = foreach$(carpet$, next$, 1)
        carpet$ = foreach$(carpet$, next$)
    next i
    return carpet$
end sub
 
print replace$(sierpinskiCarpet$(3), ",", "\n")