Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|cite|improve this question
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
up vote 2 down vote accepted

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?

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.