Yesterday, 11:58 AM
Seems to me that what you have here is a simple less than/greater than comparison.
Take your ratio and multiple that out. For example 2 x 3 = 6... you can put six or fewer items in a 2 x 3 grid. Anything more than that won't work without doubling up.
So the initial compare is easy... But how do you figure out how close you can come if you do double up that ratio? For example, you have 23 items?
You multiply that value by (x ^ 2) and see what fits.
Say a 1 x 1 grid. 1 * 1 = 1. You can put 1 item in that grid.
2 * 2 = 4. (1 * 2 ^ 2)
3 * 3 = 9 (1 * 3 ^ 2)
4 * 4 = 16 (1 * 4 ^ 2)
All of the above layouts are too small to fit 23 items.
5 * 5 = 25 (1 * 5 ^ 2)
Now 25 is larger than 23, so you can put your 23 items there and have 2 spaces left over.
Same way for a 2 x 3 ratio. The base is 6.
2 * 3 = 6
4 * 6 = 24 ( 6 * 2 ^ 2)
You can put your 23 items in a 4 * 6 grid.
It's a simple DO loop of comparisons where you just increment the base by x ^ 2 until it's larger than your number of items.
If you want to see what stores your numbers the most efficiently, just compare the difference in your total grid number - the number of items and save it.
For example, of the above you have 23 items:
in a 5 * 5 grid (which is based off the 1 x 1 ratio), you could have 25 items. The difference is 2 unused spots.
In a 4 * 6 grid (which is based off the 2 x 3 ratio), you could have 24 items. The difference is 1 unused spot.
The 4x6 would be more efficient at showing all your items than the 5x5 would be, with fewer blank spaces afterwards.
Just simple multiplication and equality comparison, with a little subtraction to get your leftover spots.
Take your ratio and multiple that out. For example 2 x 3 = 6... you can put six or fewer items in a 2 x 3 grid. Anything more than that won't work without doubling up.
So the initial compare is easy... But how do you figure out how close you can come if you do double up that ratio? For example, you have 23 items?
You multiply that value by (x ^ 2) and see what fits.
Say a 1 x 1 grid. 1 * 1 = 1. You can put 1 item in that grid.
2 * 2 = 4. (1 * 2 ^ 2)
3 * 3 = 9 (1 * 3 ^ 2)
4 * 4 = 16 (1 * 4 ^ 2)
All of the above layouts are too small to fit 23 items.
5 * 5 = 25 (1 * 5 ^ 2)
Now 25 is larger than 23, so you can put your 23 items there and have 2 spaces left over.
Same way for a 2 x 3 ratio. The base is 6.
2 * 3 = 6
4 * 6 = 24 ( 6 * 2 ^ 2)
You can put your 23 items in a 4 * 6 grid.
It's a simple DO loop of comparisons where you just increment the base by x ^ 2 until it's larger than your number of items.
If you want to see what stores your numbers the most efficiently, just compare the difference in your total grid number - the number of items and save it.
For example, of the above you have 23 items:
in a 5 * 5 grid (which is based off the 1 x 1 ratio), you could have 25 items. The difference is 2 unused spots.
In a 4 * 6 grid (which is based off the 2 x 3 ratio), you could have 24 items. The difference is 1 unused spot.
The 4x6 would be more efficient at showing all your items than the 5x5 would be, with fewer blank spaces afterwards.
Just simple multiplication and equality comparison, with a little subtraction to get your leftover spots.
