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

Home > Just Math
Counting words (Posted on 2022-04-27) Difficulty: 3 of 5
Given an alphabet of 3 letters i.e. a,b,c evaluate
the number of n-letter words containing even number of “a”s.

No Solution Yet Submitted by Ady TZIDON    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution | Comment 2 of 7 |
Within each n, for every even value, i, of number of a's that is less than or equal to n, the placement of the a's can be done in C(n,i) ways where i is the number of a's. For each of these, the remaining n-i letters can be either b or c, so C(n,i) needs to be multiplied by 2^(n-i).

Sigma{even i <=n} C(n,i)*2^(n-i)

clearvars, clc
for n=2:25
  tot=0;
  for i=2:2:n
    tot=tot+nchoosek(n,i)*2^(n-i);
  end
  fprintf('%2d %15d\n',n,tot);
end

count of   number of
  a's     such "words"
  
 2               1       aa: a type of lava
 3               6       baa, caa, aba, aca, aab, aac
 4              25 
 5              90
 6             301
 7             966            etc.
 8            3025
 9            9330
10           28501
11           86526
12          261625
13          788970
14         2375101
15         7141686
16        21457825
17        64439010
18       193448101
19       580606446
20      1742343625
21      5228079450
22     15686335501
23     47063200806
24    141197991025
25    423610750290


  Posted by Charlie on 2022-04-27 08:36:49
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 (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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