Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

How would you do this sort of problem in general, for example, if the the letter sequence was longer and there were more conditions?

One way I used to solve this problem was to enumerate the possibilities (I counted 14):

   L => PLAY, PLYA
  / 
 P    
  \
   A = > PALY, PLYA

   P => LPAY, LPYA
  /
L
  \ 
    A => LAYP, LAPY

    P => YPLA, YPAL
  /
Y -- L => YLPA, YLAP
  \
    A => YAPL, YALP

The other way I tried to think about this was to start with all possible combinations of the letters and subtract out letter combinations that didn't meet the given conditions.

4! - 3! if you start with A - 2 x 1 * 1 * 2 if you start with P or L but have Y as the second letter.

It would seem if you make the problem larger and add more conditions it becomes error prone to try to subtract out all the unacceptable combinations of letters.

share|improve this question
add comment

3 Answers

up vote 2 down vote accepted

There are $4!=24$ possible permutations without any restrictions. How many are bad? There are $3!=6$ that have A as the first letter, and there are $3!=6$ that have Y as the second letter, so to a first approximation there are $24-6-6=12$ allowable permutations. But some of the bad permutations are bad because they have A as first letter and Y as second letter, and we subtracted these twice: once on account of the A, and once on account of the Y. To correct that first approximation, we need to add these ‘doubly bad’ permutations back into the total. There are $2!=2$ of them, so the final count is $24-6-6+2=14$.

This technique of counting is known as the method of inclusion-exclusion and can be extended to arbitrarily large problems, though the computations may become rather extensive.

share|improve this answer
add comment

Without restrictions, there are $4!=24$ ways of rearranging the letters. $6$ have A in the first position (fix A and rearrange the others), and $6$ have Y in the second position. But now you've counted the rearrangements AY_ _ twice (once for each constraint, and they fit both), so add them back in (there are $2$) to cancel that out. So overall there are $24-6-6+2=14$ possible ways.

share|improve this answer
    
+1. This is an application of the inclusion-exclusion principle. –  Harald Hanche-Olsen Aug 23 '12 at 19:48
add comment

You can break this down into two cases.

Either the first letter is Y, or it is not Y. Thus, we have two disjoint cases.

First, let the first letter be Y. Then, for all options of letters in order, you have $$1\cdot 3\cdot 2\cdot 1 = 6.$$

Second, let the first letter not be Y. Then, we have $$2\cdot 2\cdot 2\cdot 1 = 8.$$

Adding these, because they are disjoint, leads to 14 possibilities.

share|improve this answer
    
Oops! Had a typo in my first equation that I carried through. Fixed it now :) –  Arkamis Aug 23 '12 at 19:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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