Given, six balls of different colours and six boxes of similar colour.
Condition : atmost two balls are in their corresponding colour boxes.
Case-I : No ball is in their corresponding colour box.
Number of ways
=6!(1−11!+12!−13!+14!−15!+16!)
=265
Case-II : One ball is in the corresponding colour box.
Number of ways
= 6C1⋅5!(1−11!+12!−13!+14!−15!)
=6×44=264
Case-III : Two balls are in their corresponding colour boxes,
Number of ways.
= 6C2⋅4!(1−11!+12!−13!+14!)
=15×9=135
∴ Total number of ways =265+264+135=664