# somehow hard combinatorics?

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!

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

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

$3^4$

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$

• have u taken care of the condition 'no ball has the same number as the basket it is in'? – Kiran Feb 1 '17 at 19:04
• yes. Each ball can be in one of 3 baskets. – Doug M Feb 1 '17 at 19:06
• ok, got it. thanks. – 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.

• What about the bin numbers and ball numbers not matching ? – true blue anil Feb 1 '17 at 19:13
• @trueblueanil Any ball into any of 3 bins would be the 3 bins that don't match the number on the ball. – Doug M Feb 1 '17 at 19:16
• 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 – Thomas Andrews Feb 1 '17 at 19:17
• Sorry, I got derailed by derangements ! +1 to you and @ThomasAndrews ! – true blue anil Feb 2 '17 at 11:14