Last active
March 16, 2016 22:12
-
-
Save aman-tiwari/79046b50667d2a5b9883 to your computer and use it in GitHub Desktop.
Finds best (closest to square) grid sides for a number of square tiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int n_tiles; //number of tiles | |
int grid_x = 0; | |
int grid_y = 0; | |
for(int n = 1; n < ceil(sqrt(n_tiles) + 1); n++) { | |
if(n_tiles%n == 0) { | |
grid_y = n; | |
grid_x = n_tiles/n; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment