> def carpet(n)
> n==0?"#\n":carpet(n-1).map{|l| ['\0\0\0','\0
> \0','\0\0\0'].map{|c| l.gsub(/#| /,c)}}.join
> end

If you saw this the way I saw it here, this is an unfortunate line-
wrap. That array in the first map call should be:

    ['\0\0\0','\0 \0','\0\0\0']