Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help to create the Sierpiński Carpet using recursion

 
Krupa Patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create the Sierpinski Carpet using recursion. I divided the square into nine equal squares in the three rows and three columns.
And the center sub-square is removed.
I do not know how to repeat that process for the eight remaining sub-squares which surround the center square that was “removed.”
This is my code:

Please help me.
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don’t know. But I do know you can’t work it out in code. You have to work it out on paper. What is the algorithm?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic