0
Challenge
My challenge, is for you to generate a Menger Sponge based on the level
/iteration
given. You need to draw it in 3d
, anyway you can.
Examples
Inputs: 0, 1, 2, 3
Outputs:
Background Information
What is a Menger Sponge
In mathematics, the Menger sponge (also known as the Menger universal curve) is a fractal curve. It is a three-dimensional generalization of the Cantor set and Sierpinski carpet
Properties
See https://en.wikipedia.org/wiki/Menger_sponge#Properties (too long to copy and paste)
How do I construct the sponge?
Begin with a cube (first image).
Divide every face of the cube into 9 squares, like a Rubik's Cube. This will sub-divide the cube into 27 smaller cubes.
Remove the smaller cube in the middle of each face, and remove the smaller cube in the very center of the larger cube, leaving 20 smaller cubes (second image). This is a level-1 Menger sponge (resembling a Void Cube).
Repeat steps 2 and 3 for each of the remaining smaller cubes, and continue to iterate ad infinitum.
The second iteration gives a level-2 sponge (third image), the third iteration gives a level-3 sponge (fourth image), and so on. The Menger sponge itself is the limit of this process after an infinite number of iterations.
Credit
Background info taken from this wikipedia page on Menger Sponges.
Good Luck!
Remember this is code-golf the shortest program wins!
@HyperNeutrino 3d is now required, so it's not a duplicate. – Noah Cristino – 2017-06-13T21:13:41.243
1you shouldn't change the question when 2 of us answered – J42161217 – 2017-06-13T21:16:27.690
@Jenny_mathy I don't have a choice since doing it in 2d is already a question. – Noah Cristino – 2017-06-13T21:17:31.870
I'm voting to reopen simply because this is no longer a dupe. However, you will need to tighten up the spec to allow us to onow exactly what kind of 3d output you want – Beta Decay – 2017-06-13T21:17:56.110
1Since 3D is now required (invalidating existing answers), I think the question is now unclear. There is a lot you need to specify for 3D including but not limited to viewing angle, projection, lighting, shading. – Digital Trauma – 2017-06-13T21:18:03.483
@DigitalTrauma I'm editing it right now! – Noah Cristino – 2017-06-13T21:19:58.527
@NoahCristino I think you'd do better to fix this one in the sandbox
– Digital Trauma – 2017-06-13T21:21:19.533I'm so sad this is a dupe :(. I'm already halfway done haha! This seemed like a fun one. – Magic Octopus Urn – 2017-06-13T21:22:34.717
@DigitalTrauma Should I close this, and post in sandbox, or should I just leave it open? – Noah Cristino – 2017-06-13T21:23:05.747
@carusocomputing It's not now! With 3d it's not a duplicate, I just need to specify the 3d requirements – Noah Cristino – 2017-06-13T21:24:06.483
@NoahCristino right now its effectively closed (as dup). Once you're done in the sandbox and have edited this question you may petition to the community (in comments, chat) to reopen. – Digital Trauma – 2017-06-13T21:25:33.470
@DigitalTrauma https://codegolf.meta.stackexchange.com/a/12867/61877
– Noah Cristino – 2017-06-13T21:27:30.347@NoahCristino please check out the sandbox man, it's not a dupe anymore, but you need to let this die and work out the kinks! I've actually posted a suggestion on the Meta site due to this question: https://codegolf.meta.stackexchange.com/questions/12869/resurrection-sandbox
– Magic Octopus Urn – 2017-06-13T21:38:14.817@carusocomputing I'm working out the kinks here: https://codegolf.meta.stackexchange.com/a/12867/61877 But, I don't know what you mean about resurrecting, since I posted it today, and the other challenge is about 2d menger sponges (Sierpinski Carpets)
– Noah Cristino – 2017-06-13T21:42:26.287@NoahCristino your original question is the duplicate, and you already have 2 answers. Once an answer is posted, the question is "more-or-less" locked. – Magic Octopus Urn – 2017-06-13T21:56:28.290