How to get the rows and columns of a square matrix when you have an array

Yesterday I was reading the book Beautiful Code when I found out a silly, and even evident, way for  finding out the number of columns/rows of an square matrix when represented in an array.

Just make the square root of the length of the array.

It is so simple that I cannot imagine why I never thought about this way before.

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *