Infinite recursive shape: To create a recursive function to draw boxes inside each other in array on the basis of 3 parameters
width
height
and padding
cd tradeling-draw && npm i && npm run dev
I am using jest to write unit tests inside __tests__
folder and using test_data.json
file to loop through and validate object return from draw function is equivalent to test data object
npm run test
Base case if width or height <= padding + 2 then drawing inner most box
Returning array by calling draw fn recursively to create outer boxes
More detailed comments inside helpers/index.tsx
file.
O(n^2) - Quadratic
Width: 20, Height:40, padding: 6)
(Width: 60, Height:60, padding: 10)
(Width: 80, Height:100, padding: 20)