All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > General
ABCDEABCDE is one (Posted on 2006-05-17) Difficulty: 2 of 5
How many arrangements of the letters AABBCCDDEE are there such that there are no double letters in the sequence?

See The Solution Submitted by Jer    
Rating: 4.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution (spoiler) and hint for analytic solution | Comment 2 of 3 |

DECLARE SUB permute (a$)
DEFDBL A-Z
CLS
a0$ = "abcdefghij"
FOR n = 1 TO 5
  ct = 0
  a$ = LEFT$(a0$, n) + LEFT$(a0$, n): h$ = a$
  DO
    good = 1
    FOR i = 1 TO LEN(a$) - 1
      IF MID$(a$, i, 1) = MID$(a$, i + 1, 1) THEN good = 0: EXIT FOR
    NEXT
    IF good THEN ct = ct + 1
    permute a$
  LOOP UNTIL a$ = h$
  PRINT ct
NEXT

(subroutine permute is found elsewhere on this site)

finds

0
2
30
864
39480

representing the number of ways of arranging AA, AABB, AABBCC, AABBCCDD, and AABBCCDDEE, respectively, with no two of the same letter adjacent.

So 39,480 is the answer to this puzzle, but what is the theory behind it?

Entering this sequence of numbers into the online encyclopedia of integer sequences (Sloane), we get

A114938  Number of permutations of the multiset {1,1,2,2,....,n,n} with no two consecutive terms equal.  
 
 0, 2, 30, 864, 39480, 2631600, 241133760, 29083420800, 4467125013120, 851371260364800, 197158144895712000, 54528028997584665600, 17752366094818747392000, 6720318485119046923315200 
 
Sloane gives a formula of:

a(n)=Sum_{k=0..n}((C(n, k)*(-1)^(n-k)*(n+k)!)/2^k)

It would be interesting to see how this formula was derived.

The summations themselves, carried out for the first 7 of the series, are:

-1
 1
 1 *** 0
 2
-6
 6
 2 *** 2
-6
 36
-90
 90
 3 *** 30
 24
-240
 1080
-2520
 2520
 4 *** 864
-120
 1800
-12600
 50400
-113400
 113400
 5 *** 39480
 720
-15120
 151200
-907200
 3402000
-7484400
 7484400
 6 *** 2631600
-5040
 141120
-1905120
 15876000
-87318000
 314344800
-681080400
 681080400
 7 *** 241133760
 
via
10   for N=1 to 7
20    Tot=0
30    for K=0 to N
40     Term=combi(N,K)*(-1)^(N-K)*!(N+K)//2^K
50     print Term
60     Tot=Tot+Term
70    next
80    print N;"***";Tot
90   next

  Posted by Charlie on 2006-05-17 10:35:45
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2017 by Animus Pactum Consulting. All rights reserved. Privacy Information