DEV Community

Discussion on: The challenge to make a shape area calculation in CodeSignal

Collapse
 
graffitimsx profile image
Rudolf Arthur Frans Gutlich

the simpler way I think is:


return Math.pow(n,2) + Math.pow(n-1,2)

Enter fullscreen mode Exit fullscreen mode

Just rotate the grid view by 45º and check the patterns