2
A menger sponge is a fractal made out of cubes within cubes within cubes...
If you start with a cube, on each face there are 9 squares. The middle square becomes empty (or 0). The other 8 squares iterate this process. They each get split up into 9 squares and the middle square face is taken out.
The goal today is to generate a menger sponge face, not the cube.
Here are some example given an input for the number of iterations.
0:
1
(No holes or anything, solid face)
1:
1 1 1
1 0 1
1 1 1
2:
111111111
101101101
111111111
111000111
101000101
111000111
111111111
101101101
111111111
To complete the challenge, based on an input, return a set of 1 (filled in blocks) and 0 (empty blocks) with spaces between or not.
This is code golf, lowest number of bytes wins.
1
Also known as a Sierpinski carpet
– H.PWiz – 2017-09-24T13:04:01.527