"Fractals" is like string replace in 2D.
A fractal is composed of "#" and ".". We have a replacement pattern for each symbol. Here we chose to replace each "#" by :
##
#.
And each "." by :
..
..
We begin with a simple "#" :
#
(that's our iteration 0)
For each iteration, we replace the characters by the corresponding pattern, so our first iteration will be :
##
#.
(Because we replaced the single "#" by it's pattern)
Our second iteration will be :
## ## ####
## #. #. #.#.
#. -> -> ##..
## .. #...
#. ..
With more iterations we can obtain something like this :
################
#.#.#.#.#.#.#.#.
##..##..##..##..
#...#...#...#...
####....####....
#.#.....#.#.....
##......##......
#.......#.......
########........
#.#.#.#.........
##..##..........
#...#...........
####............
#.#.............
##..............
#...............
- Compile via makefile
make
- Run program
./fractals <n iter> <pattern for "#"> <pattern for ".">
You must use "@" as linebreak in the patterns.
You can use rectangle patterns.
But all lines must have the same length and the two patterns must have the same dimensions.