# Number of circles packed into a rectangle [closed]

Calculate the maximum number of circles of radius r that can fit in a rectangle with width x and height y. Write a function that take r, x and y as input and returns the number of circles that fit in the rectangle.

## closed as unclear what you're asking by user202729, Jonathan Allan, Erik the Outgolfer, mbomb007, manatworkNov 3 '18 at 17:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• I would suggest to add some testcases so that we can know if any answer is correct. – tsh Nov 3 '18 at 15:44
• It appears to me that one could fit at least one more circle, by expanding the second-to-last row to have 10 circles in it, such that the last three rows touch each other orthogonally. Do we not have to handle such cases? – ETHproductions Nov 3 '18 at 15:56
• Would it make sense to just normalise and say r is always 1? This way there are only 2 inputs - I believe every answer will divide through by r. – Jonathan Allan Nov 3 '18 at 15:58
• Do we have to support floats or are x,y,r guaranteed to be whole numbers? – Black Owl Kai Nov 3 '18 at 16:34
• Without the "triangular lattice" restriction we have math.stackexchange.com/questions/701/… , which is unsolved. – user202729 Nov 3 '18 at 16:45