Interview Question

    What is the maximum number of circles you can fit into a rectangle?

Describe a generic approach given a rectangle of length l, and width w, filling with circles of radius r




Answers


  • 513
    @amaghucollins

    (l-r) x (w-r)


  • 11
    @gerrit

    This question may seem like a TRICK QUESTION, since there is no practical solution.   In fact, an entire website is devoted to this problem: https://www.engineeringtoolbox.com/circles-within-rectangle-d_1905.html
    
    However, there is a "right" and a "wrong" answer.  The employer wants to gauge your thought process and see how you would approach a difficult question.  Therefore if you state your assumptions and describe your approach, you get the "right" answer.
    
    A good answer would be to provide a "lower bound".  For example, carve the rectangle into squares size 2r, each of which can hold a single circle or radius r.  This would give an answer of floor(l / (2r)) * floor(w / (2r)).  In other words, for a 10x10 rectangle, it could hold 25 circles of radius 1.  Each circle fits into a 2x2 square, and you can git these squares 5 across and 5 down.
    
    Of course, this is not the "correct" answer, because you could use more efficient stacking techniques.  It is a good "lower bound", in that the answer must be at least the number you suggest.  Notice the replies to this question, very few people actually attempt to solve the problem, so if you go through the legwork of providing a "lower bound" then you will be in the top 1% of responders, a very good lower bound for your interview.


  • 5

    Check the answer at this website: https://math.stackexchange.com/questions/2548513/maximum-number-of-circle-packing-into-a-rectangle


  • 2

  • 1

    infinite number

Interview Questions

We're compiling a definitive list of interview questions.

Take a practice interview and score yourself.

<< Return to Index