Please Forward: Ruby Quiz Submission

From: "Justin Ethier" <justin.ethier@gmail.com>
Date: May 29, 2007 12:42:14 PM CDT
To: submission@rubyquiz.com
Subject: Please Forward: Ruby Quiz Submission

Hello Everyone,

Here are links to the code for my solution:

http://justin.ethier.googlepages.com/fractal_model.rb
http://justin.ethier.googlepages.com/fractal_draw.rb
http://justin.ethier.googlepages.com/tc_fractal_modeler.rb

Basically there are 2 parts to it. The first one takes the depth level and base fractal shape, and recursively creates a list of directions that can be traced to draw the fractal. For example, the fractal at level 1 is defined as:

[0, 90, 0, 270, 0] also written as [Right, Up, Right, Down, Right]

The second part creates an RMagick canvas and traces out each line one-at-a-time to draw the actual fractal.
There are probably more efficient ways of doing this, but this approach works well at lower levels.

Thanks,

Justin

ยทยทยท

Begin forwarded message: