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

this problem is originally from a programming task i am on.

there is a number of playing cards n. the width of each card is w.

now the cards should be placed next to each other on a table with equal space. the table's width is also limited, let's call this t. so t is the available width that should be used by the cards.

now i am looking for a spacing-distance that should be put between each card depending on the above variables. cards can overlap.

so far i simply tried to interpolate depending on the number of cards, but it doesnt work out very well. i think i am missing to take the card width into account, but i dont know how.


share|cite|improve this question
up vote 4 down vote accepted

Let the distance between the centers of adjacent cards be $x$. Then $(n-1)x+w=t$, so $x=(t-w)/(n-1)$. That tells you how far apart to put (the centers of) adjacent cards.

share|cite|improve this answer
thanks, but in general the width of a card is a lot smaller than the width of the table. so your formula will give negative values. is that on purpose? – clamp Jul 12 '11 at 12:44
@clamp: Given your variables, $t \gt w,$ so $x \gt 0$. I don't see a negative answer. Say the table is $30$ inches, and $18$ cards are $1$ inch each. Then $x=\frac{29}{17}$ – Ross Millikan Jul 12 '11 at 12:50
well the formula was w-t before the edit. – clamp Jul 12 '11 at 13:29
Thanks, Chris, for fixing my typo. clamp, people make mistakes; what you do when you run into one is go back one equation and see if you can figure out what went wrong. My first equation was right, and even though I failed to solve it correctly, perhaps you could have? – Gerry Myerson Jul 13 '11 at 1:42

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.