In a hospital, there are 7 patients (Doc, Grumpy, Happy, Sleepy, Bashful, Sneezy, and Dopey) who need to be assigned to 3 doctors (Huey, Dewey, and Louie). In how many ways can the patients be assigned to the doctors so that each patient is assigned to exactly one doctor and each doctor is assigned at least one patient?
If we impose no restrictions initially, each of the 7 patients can be assigned to one of 3 doctors, which means that there are $3^{7}$ ways to assign the patients to doctors.

To determine the number of ways in which the patients can be assigned to doctors so that each doctor is assigned at least one patient, we subtract from $3^{7}$ the number of ways in which at least one doctor has 0 patients.

This can happen if all of the patients are assigned to one doctor. There are 3 ways to do this (all patients assigned to Huey, all patients assigned to Dewey, or all patients assigned to Louie). This can also happen if all of the patients are assigned to two doctors and each of these two doctors are assigned at least one patient.

If each of the 7 patients are assigned to Huey and Dewey, for example, then there are 2 choices for each patient, giving $2^{7}$ ways minus the 2 ways in which all of the patients are assigned to Huey and in which all of the patients are assgined to Dewey. This gives $2^{7}-2$ ways of assigning the patients in this way.

Similarly, there are $2^{7}-2$ ways of assigning the patients to Huey and Louie, and $2^{7}-2$ ways of assigning the patients to Dewey and Louise.

Overall, this means that there are $3^{7}-3-3\left(2^{7}-2\right)=2187-3-3(126)=1806$ ways of assigning the patients to the doctors.

ANSWER: 1806