/tradeling-draw

Infinite recursive shape app built with React and Next using typescript

Primary LanguageTypeScript

tradeling-draw

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

Built With

Installing & Running

cd tradeling-draw && npm i && npm run dev

Testing

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

Draw Recursive Fn

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.

Big O

O(n^2) - Quadratic

Travis

Build Status

Deployed on Now

Screen shots

  1. Width: 20, Height:40, padding: 6)

  1. (Width: 60, Height:60, padding: 10)

  1. (Width: 80, Height:100, padding: 20)