I encountered a counting problem, which seems pretty easy but it is actually hard when I tried it...

There are four baskets numbered from 1 to 4 and four balls numbered from 1 to 4. Each basket is allowed to have at most two balls. In how many ways can the balls be placed in the baskets such that no ball has the same number as the basket it is in?

I figured that without any restriction, there are total of 204 ways. I don't know how to continue from that. Any help will be greatly appreciated!

  • $\begingroup$ This is a modified form of derangrment. Check it. I will try to come up with an answer. $\endgroup$ – SchrodingersCat Feb 1 '17 at 18:39

Each ball can go into any basket but the one with its own number.


But we can't put more than two balls in any one basket.

How many of the 81 above put 4 balls in 1 basket. None. Because that would put a ball in the basket with its own number.

How many of the 81 above put 3 balls in 1 basket.

I can put balls 2,3,4 in basket number $1.$ And, ball $1$ goes in basket 2,3 or 4.

And then we can do something similar for each of the other $3$ baskets.

$3^4 - 3\cdot4 = 69$

  • $\begingroup$ have u taken care of the condition 'no ball has the same number as the basket it is in'? $\endgroup$ – Kiran Feb 1 '17 at 19:04
  • $\begingroup$ yes. Each ball can be in one of 3 baskets. $\endgroup$ – Doug M Feb 1 '17 at 19:06
  • $\begingroup$ ok, got it. thanks. $\endgroup$ – Kiran Feb 1 '17 at 19:06

Hint: You can put any ball into any of three bins. Then you have to subtract the cases when three balls made it into one bin and the fourth into another.

  • $\begingroup$ What about the bin numbers and ball numbers not matching ? $\endgroup$ – true blue anil Feb 1 '17 at 19:13
  • $\begingroup$ @trueblueanil Any ball into any of 3 bins would be the 3 bins that don't match the number on the ball. $\endgroup$ – Doug M Feb 1 '17 at 19:16
  • $\begingroup$ My answer covers that. If I didn't have the condition that a bin can't get its own ball, then each ball could go into any of four bins, not any of three bins. And I'd have to exclude the case where four balls went into the same bin, too. @trueblueanil $\endgroup$ – Thomas Andrews Feb 1 '17 at 19:17
  • $\begingroup$ Sorry, I got derailed by derangements ! +1 to you and @ThomasAndrews ! $\endgroup$ – true blue anil Feb 2 '17 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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