5 kyu

Recursive ASCII Fractals

Description:

Fractals are fun to code, so let's make some.

Your task is to write a function that recursively generates an ASCII fractal.

  • The function will take a list[str] representing rows of a seed pattern and an int number of iterations
  • The seed pattern will be a rectangle containing two types of characters, * and .
  • Each new iteration, every * in the starting seed is replaced by a copy of the last iteration.
  • Empty space is filled with .
Example for the seed pattern:

 ***
 *.*
 ***
 
1st iteration:

 ***
 *.*
 ***
 
2nd iteration:

 *********
 *.**.**.*
 *********
 ***...***
 *.*...*.*
 ***...***
 *********
 *.**.**.*
 *********
 
3rd iteration:

 ***************************
 *.**.**.**.**.**.**.**.**.*
 ***************************
 ***...******...******...***
 *.*...*.**.*...*.**.*...*.*
 ***...******...******...***
 ***************************
 *.**.**.**.**.**.**.**.**.*
 ***************************
 *********.........*********
 *.**.**.*.........*.**.**.*
 *********.........*********
 ***...***.........***...***
 *.*...*.*.........*.*...*.*
 ***...***.........***...***
 *********.........*********
 *.**.**.*.........*.**.**.*
 *********.........*********
 ***************************
 *.**.**.**.**.**.**.**.**.*
 ***************************
 ***...******...******...***
 *.*...*.**.*...*.**.*...*.*
 ***...******...******...***
 ***************************
 *.**.**.**.**.**.**.**.**.*
 ***************************
  • Input patterns will always be rectangular.
  • For values of i < 1 or seeds with rows that are all empty strings, return [].
  • Your function will be tested on both fixed and random inputs.

Tests

  • Your solution must be efficient, as random tests will be on up to 9x9 input seeds
  • There are 60 random tests with a seed of size 2 x n (n ranges from 0-9 and there are 5 tests for each value of n, each having i ranging from 0-4)
  • There are 25 random tests with seed n x n where n ranges from 5-9. i = 4
Mathematics
Algorithms
Geometry
ASCII Art
Performance

Similar Kata:

More By Author:

Check out these other kata created by skidd

Stats:

CreatedNov 19, 2022
PublishedNov 19, 2022
Warriors Trained373
Total Skips8
Total Code Submissions435
Total Times Completed52
Python Completions52
Total Stars20
% of votes with a positive feedback rating95% of 20
Total "Very Satisfied" Votes18
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • skidd Avatar
  • dfhwze Avatar
Ad