0
$\begingroup$

In a grid of variable width, with a variable number of columns having a minimum and maximum allowed width, how can I calculate the number of columns for any given grid width so they fall within the minimum and maximum allowed column width?

Phrased differently, if I have a magical shrinking chess board, and each tile on the board must be between 2cm-3cm wide, is it possible to calculate how many tiles are allowed in each row so that each tile falls between the minimum and maximum allowed widths as the board shrinks?

Sorry if this is a ridiculous question, I am a UI developer with no maths background. :)

  • 1
    What do you want to do if the minimum and maximum column widths are $10$ and $12$, and the grid is $25$ units wide?2012-05-06

1 Answers 1

2

It is not a ridiculous question, but maybe not well stated. If your input is the w=width and mnc=minimum column width, mxc=maximum column width, the minimum number of tiles is $\frac w{mxc}$ rounded up to the next whole number. The maximum number of tiles is $\frac w{mnc}$ rounded down. This works if the tiles can be any rational width. If they need to be integral, it is harder. Is that what you were looking for?