# How many columns in a grid of arbitrary width, with minimum and maximum allowed column widths?

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. :)

-
It's not clear what's changing and what's constant. You say the number of columns is variable, which sounds like you are saying the number of tiles in each row changes over time; but then you ask how many tiles are allowed in each row, which makes it sound like the number of tiles in each row doesn't change over time. – Gerry Myerson May 6 '12 at 3:19
What do you want to do if the minimum and maximum column widths are $10$ and $12$, and the grid is $25$ units wide? – Rahul May 6 '12 at 3:20

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?