Using an ordered alphabet of 26 letters, how many ways are there to choose a set of six different letters such that no two letters in the set are adjacent in the alphabet?
For instance, { I S O K A Y } is a valid set of six letters, but { V E T O I F } is not because E and F are both in the set.
Note : As always, a "set" is considered unordered. Hence, { I S O K A Y } and { Y A K O S I } and { A I K O S Y } are considered the same set.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Sir, I maybe misunderstanding the question.
The question says Ordered alphabet I thought it was 5 4 2 6 4 × 6 ! .
Log in to reply
The word "ordered" must have been added by the Brilliant staff-- not my original formulation!
But it means that the alphabet is ordered: that is, given any two letters x = y , we have either x < y or x > y , with the usual asymmetry and transitive properties.
It does not mean that the sets chosen from them are ordered. This is illustrated in the given examples.
Log in to reply
Okay... Thanks for explanation.
from what i can tell, Brilliant got it wrong and so too do you in trying to reconcile the the manner in which Brilliant edited his problem OR in your original presentation. the use of { } indicates an UNORDERED set while the use of ( ) indicates an ORDERED set. further, UNORDERED expressly means the order DOES NOT matter. that is, no matter what order the objects are written, the set is the same. ORDERED, meanwhile, means order DOES matter. hence, (A, B) is different than (B,A).
so the use of the { } is incongruous with the term ORDERED and the problem becomes ambiguous.
Log in to reply
@Mark Brown – The alphabet is said to be ordered; more correctly, it is a fully ordered set. This means that it is a set A such that for any x = y ∈ A , we have either x < y or x > y . Thus the alphabet is not merely the undordered set { A , B , C , … , X , Y , Z } but the structured set { A < B < C < ⋯ < X < Y < Z } or, if you will, the ordered tuple ( A , B , C , ⋯ , X , Y , Z ) .
This allows us to speak about adjacent letters: two letters x < y are adjacent in the alphabet iff there is not z ∈ A such that x < z < y . Without stating or assuming that the alphabet is ordered, the problem makes no sense.
But the chosen sets of six letters are not said to be ordered; and since the word "set" is used and the curly-bracket notation { } , they must be considered unordered sets. Thus, we count { A , I , K , O , S , Y } and { I , S , O , K , A , Y } as the same set. This in no way contradicts the fact that the alphabet has an ordering!
Your criticism, I believe, arises from confusing the ordering of the alphabet and the ordering of the sets . The problem is not stated incorrectly. However, to prevent further misconception, I will edit the problem to specity that the chosen sets are "unordered".
from what i can tell, Brilliant got it wrong and so too does the originator of the problem in his trying to reconcile the the manner in which Brilliant edited his problem OR in his original presentation. the use of { } indicates an UNORDERED set while the use of ( ) indicates an ORDERED set. further, UNORDERED expressly means the order DOES NOT matter. that is, no matter what order the objects are written, the set is the same. ORDERED, meanwhile, means order DOES matter. hence, (A, B) is different than (B,A).
so the use of the { } is incongruous with the term ORDERED and the problem becomes ambiguous.
It is not specified that we cannot choose the same letter multiple times. In this case we have other valid sets, like { A A A A A A } .
Log in to reply
This is implied by the word "set". A set either contains an item x ∈ S or does not contain it x ∈ S .
The variant of a set in which repetition is allowed is called a bag .
Log in to reply
However, for sake of clarity I will insert the word "distinct" in the problem.
It isn't implied by the word "set", { A , A , A , A , A , A } = { A } can still be viewed as a set.
The set { A , A , A , A , A , A } consists only one element.
It says a set of 6 different letters, so of course you can't choose the same letter multiple times.
Log in to reply
Actually, he added " different " thanks to my comment (cf. his replies below) :)
The question would be unambiguous if it was " { I , S , O , K , A , Y } " is a valid set of six letters.
Sadly, Grafton will not be completing the Z volume, as she recently passed away.
Meanwhile, I'm here foolishly trying to solve this by complementary counting and principles of inclusion and exclusion. I realized this method like an hour later. But very clean method. And must've been a long way home if you were able to calculate such a large number in your head.
Log in to reply
About three miles :) To evaluate 2 1 ⋅ 1 9 ⋅ 1 7 ⋅ 8 , I took these steps:
2 1 ⋅ 1 9 = ( 2 0 + 1 ) ( 2 0 − 1 ) = 2 0 2 − 1 = 4 0 0 − 1
1 7 ⋅ 8 = 1 3 6
2 1 ⋅ 1 9 ⋅ 1 7 ⋅ 8 = ( 4 0 0 − 1 ) ⋅ 1 3 6 = 5 4 4 0 0 − 1 3 6 = 5 4 2 6 4 .
Hello, does it count if I solved it writing a small python script?
Log in to reply
If you get the right number, Brilliant will give you points. So it counts.
The problem was intended as practice with combinatorics, but if it helps you practice your coding skills, kudos to you! Feel free to post your script as a solution.
your problem doesnt specify if order matters...from the wording i would say it does not matter as you state "how many different ways can you choose a set of 6" so each permutation of any one combination of letters would each be a different way to choose...hence the answer would be 54264*720.....whatever that may be
Log in to reply
It says to "choose" a set of 6, not "make" a set of 6, thus order is not even relevant in this case. Think of it as the binomial coefficient or n choose r, this is an unordered choosing. Choosing a set of 6 is not the same as making a set of 6.
Relevant wiki: Permutations - Problem Solving
Imagine putting 20 identical objects in a straight line, and then adding 6 objects of another type between them. Now you have a line of 26 objects, 6 of them different from the rest. Apply the alphabet to this line of objects, and imagine that the 6 “distinct” objects highlight 6 letters in the matching position. This is your “answer set”. Notice how the way you place these 6 objects into the rest determines the letters in the answer set, each unique way representing an unique solution. So now the problem becomes “how to place 6 objects between 20 other objects?” The solution is apparent: There are 21 spaces for 6 objects, so the answer is
( 6 2 1 ) = 5 4 2 6 4
Intuitive!
quite intuitive but if you had 20 objects with 6 other objects placed "between" them you would have only 19 spaces for 6 objects. the terminology should be a bit different to describe what you are saying...such as 21 spaces to place 6 objects adjacent to the 20 objects
-So, now the problem is equivalent to finding the number of ways to choose 6 integers from the first 2 6 integers so that no two chosen integers are consecutive integers.
Let a , b , c , x , y , z be six integers (in increasing order).
Note that, even when any two of a , b , c , x , y , z are consecutive, no two of a , b + 1 , c + 2 , x + 3 , y + 4 , z + 5 are consecutive.
That means, we can choose any six integers a , b , c , x , y , z from the set of { 1 , 2 , 3 , … … … , 2 1 } , then choose the letters represented by a , b + 1 , c + 2 , x + 3 , y + 4 , z + 5 .
Hence the number of ways is: ( 6 2 1 ) = 5 4 2 6 4 .
You have shown one way to construct such a set, But are all sets really represented by such choice of integers?
Log in to reply
Good question.
I believe, you are asking if, for every ( a , b + 1 , c + 2 , x + 3 , y + 4 , z + 5 ) with 1 ≤ a < b + 1 < c + 2 < x + 3 < y + 4 < z + 5 ≤ 2 6 , there exists ( a , b , c , x , y , z ) with 1 ≤ a < b < c < x < y < z ≤ 2 1 ? Of course.
As no two of ( a , b + 1 , c + 2 , x + 3 , y + 4 , z + 5 ) are consecutive, we have a < b < c < x < y < z . As 1 ≤ a , we also have 1 ≤ a . And z + 5 ≤ 2 6 ensures us that z ≤ 2 1 , establishing us at completeness.
I think your logic is incomplete..
If u make the row in ascending order (since it is collection, u can do that for the ease of understanding...)
U get your constraint as 1 <= a <= b+1 <= c+2 <= d+3 <= e+4 <= f+5 <= 26
then your logic will be complete.
With 1<= a <= 16
2<= b <= 17
3 <= c <= 18
4 <= d <= 19
5 <= e <= 20
6 <= f <= 21
Thus chosing any 6 from the set of 21 numbers will make it.
You chose a set of numbers but put in a box with the respective shifts of those numbers... which will never collide.
One thing.. chosing a combination even from an ordered set wont remain ordered.. but you will always get an unique valid combo from each of ur unordered choice.
But i followed an addition process that increases in folds.. just like unfolding a paper.. And used calculator.
Manual calculation required some long sums like techniques required in calculating cumulative frequencies in statistics.. I felt that gave me a detailed and clearer view of the entire thing. Yaa.. i m less smart i think. Can not post my solution any more here.
The following is a more empirical approach that derives a formula for any set of k different non-adjacent items (a k -set) from an ordered collection that contains n items (a n -collection). By experimentally checking the combinations of 2 different non-adjacent letters, you can quickly induce that each new letter n increases the number of possible combinations by n − 2 . That is, when you have a 4-collection, you have 3 2-sets. When you increase the number of letters to 5, you get 3 + ( 5 − 2 ) = 6 2-sets. When you consider 3-sets, each new letter that you add, can be added to a set that contains any letter, except: 1) itself; 2) it's adjacent letter(n-1). That means that it will generate a new set with any ( k − 1 ) -set of a ( n − 2 ) -collection. For example, a 5-collection contains 1 3-set. A 6-collection will contain the same set AND any new sets generated by the new letter. In that case that means that it will generate 1 + the number of 2-sets of a 4-collection. So the number of 3-sets in a 6-collection is 1 + 3 = 4 .
Now we can generalize a formula:
N ( k -sets / n -collection ) = N ( ( k − 1 ) -sets / ( n − 2 ) -collection ) + N ( ( k -sets ) / ( n − 1 ) -collection)
Where N ( x ) means number of x , and k -sets / n -collection means k-sets from an n-collection.
Number of Letters | 2s | 3s | 4s | 5s | 6s |
3 | 1 | 0 | 0 | 0 | 0 |
4 | 3 | 0 | 0 | 0 | 0 |
5 | 6 | 1 | 0 | 0 | 0 |
6 | 10 | 4 | 0 | 0 | 0 |
7 | 15 | 10 | 1 | 0 | 0 |
8 | 21 | 20 | 5 | 0 | 0 |
9 | 28 | 35 | 15 | 1 | 0 |
10 | 36 | 56 | 35 | 6 | 0 |
11 | 45 | 84 | 70 | 21 | 1 |
12 | 55 | 120 | 126 | 56 | 7 |
13 | 66 | 165 | 210 | 126 | 28 |
14 | 78 | 220 | 330 | 252 | 84 |
15 | 91 | 286 | 495 | 462 | 210 |
16 | 105 | 364 | 715 | 792 | 462 |
17 | 120 | 455 | 1001 | 1287 | 924 |
18 | 136 | 560 | 1365 | 2002 | 1716 |
19 | 153 | 680 | 1820 | 3003 | 3003 |
20 | 171 | 816 | 2380 | 4368 | 5005 |
21 | 190 | 969 | 3060 | 6188 | 8008 |
22 | 210 | 1140 | 3876 | 8568 | 12376 |
23 | 231 | 1330 | 4845 | 11628 | 18564 |
24 | 253 | 1540 | 5985 | 15504 | 27132 |
25 | 276 | 1771 | 7315 | 20349 | 38760 |
26 | 300 | 2024 | 8855 | 26334 | 54264 |
Your table replicates Pascal's triangle. In row r column c you place the value N r , c = ( c r − c ) , and the well-known property ( k n ) = ( k − 1 n − 1 ) + ( k n − 1 ) translates to N r , c = N r − 1 , c + N r − 2 , c − 1 .
The answer is 54264.
I wrote a little program for Liberty Basik to find the answer.
Initially the program was generating the combinations and was able to print them if I wanted to.
Then I minimized it only to count the number of combinations.
First: Let's use numbers from 1 to 26 instead of letters from A to Z.
Second: Let's use the variable "Distance" so that Distance = 1 means no restrictions for adjacent numbers.
This would be the case for the full number of combinations, which is (26.25.24.23.22.21) / (1.2.3.4.5.6) = 230230.
Our task is to make Distance = 2 (to skip one position and avoid adjacent numbers).
This universal approach prompted me to do a small research and find all the answers
for Distances from 1 to 5 (5 by the way is the maximal distance possible).
Here are the results:
Distance=1 - 230230 combinations with adjacent numbers like 123456, 123457, 123458, ... , 21,22,23,24,25,26;
Distance=2 - 54264 combinations with no adjacent numbers like 1,3,5,7,9,11, ... , 16,18,20,22,24,26;
And now even stronger restrictions
Distance=3 - 8008 combinations like 1,4,7,10,13,15, ... , 11,14,17,20,23,26;
Distance=4 - 462 combinations like 1,5,9,13,17,21, ... 6,10,14,18,22,26;
Distance=5 - 1 combination which should be 1,6,11,16,21,26.
And here is the minimized program:
for Distance = 1 to 5
print Distance;" - ";
Counter = 0
for a = 1 to 26
for b = a + Distance to 26
for c = b + Distance to 26
for d = c + Distance to 26
for e = d + Distance to 26
for f = e + Distance to 26
Counter = Counter + 1
next f
next e
next d
next c
next b
next a
print Counter
next Distance
Nice generalization!
Mathematically, if the minimum distance is d , the length of the alphabet n , and the number of items to be chosen is k , then the number of possible choices is N ( n , k , d ) = ( k n − ( d − 1 ) ( k − 1 ) ) . Thus, the values you found may be reproduced as N ( 2 6 , 6 , 0 ) = ( 6 3 1 ) = 7 3 6 2 8 1 ; N ( 2 6 , 6 , 1 ) = ( 6 2 6 ) = 2 3 0 2 3 0 ; N ( 2 6 , 6 , 2 ) = ( 6 2 1 ) = 5 4 2 6 4 ; N ( 2 6 , 6 , 3 ) = ( 6 1 6 ) = 8 0 0 8 ; N ( 2 6 , 6 , 4 ) = ( 6 1 1 ) = 4 6 2 ; N ( 2 6 , 6 , 5 ) = ( 6 6 ) = 1 .
We will construct a solution by stepwise selecting the (alphabetically) next letter. The first letter cannot come after P, because the alphabetically last solution is { P , R , T , V , X , Z } . So there are 16 choices for the first letter. When the i th letter l i has been selected, then the next letter comes at least two places after l i and comes before the ( 1 4 + 2 i ) th position. This yields the following expression: l 1 = 1 ∑ 1 6 l 2 = l 1 + 2 ∑ 1 8 l 3 = l 2 + 2 ∑ 2 0 l 4 = l 3 + 2 ∑ 2 2 l 5 = l 4 + 2 ∑ 2 4 l 6 = l 5 + 2 ∑ 2 6 1 . This sums up to 5 4 2 6 4 .
The big question is how to evaluate this sum...
Log in to reply
∑ l 6 = l 5 + 2 2 6 1 = 2 5 − l 5 , so ∑ l 5 = l 4 + 2 2 4 ∑ l 6 = l 5 + 2 2 6 1 = ∑ l 5 = l 4 + 2 2 4 ( 2 5 − l 5 ) . Repeating this process always yields a linear expression in l i with i always diminishing. Or you know, just put it in a computer.
Log in to reply
One of the challenges in mathematics is to simplify processes that are repetitive or convoluted, by discovering patterns or tying them in with known relations. In this case, the theory of binomial coefficients provides an elegant method to deal with the situation.
Log in to reply
@Arjen Vreugdenhil – By rewriting the sum as l 1 = 1 ∑ 1 6 l 2 = l 1 + 1 ∑ 1 7 l 3 = l 2 + 1 ∑ 1 8 l 4 = l 3 + 1 ∑ 1 9 l 5 = l 4 + 1 ∑ 2 0 l 6 = l 5 + 1 ∑ 2 1 1 one could use the same reasoning as above to see that this expression describes the number of ways to chose six numbers l 1 < l 2 < ⋯ < l 6 from a set of 21 numbers. We know this number is ( 6 2 1 ) .
Log in to reply
@Sam Adriaensen – Right!
Your rewriting of the sums is identical to my use of pairs of boxes instead of individual boxes.
Separate the alphabet into two groups of 13 non-adjacent letters ACEGIKMOQSUWY and BDFHJLNPRTVXZ
Form all permutations of 6 letter words for each group of 13 letters:
2x13P6=2x13x12x11x10x9x8 = 2471040
In addition, form 6 letter words from ACEGIK and NPRTVXZ by replacing each letter one at a time from ACEGIK with a letter from NPRTVXZ. Also, do the same for BDFHJL and MOQSUWZ.
2x7x6x5x4x3x2x1=10800
Total 6 letter words with non-adjacent letters: 2546640
Log in to reply
First of all, we are looking at sets of letters, not words. Thus, A C E G I K and K I C A E G count as the same solution. Instead of permutations, you would need combinations: there are 2 ⋅ 1 3 C 6 = 3 4 3 2 solutions that consist entirely of "odd" or entirely of "even" letters-- your number 2 4 7 1 0 4 0 divided by 6 ! .
Next, you are overlooking possibilities such as A D F I K M .
A rude brute force way to find it out in Python :-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Let there be a row of 21 identical objects. Select 6 of them, then insert 5 more between adjacent pairs to ensure that none of the six are adjacent. Overlay the alphabet onto the row of 26 objects.
There are 21C6 ways of doing this, each of which corresponds to one set of valid letters.
Problem Loading...
Note Loading...
Set Loading...
Relevant wiki: Permutations - Problem Solving
Think of a string of 27 boxes, one empty, followed by the letters of the alphabet: A B C ⋯ Z
Underneath we must place 6 pairs of boxes like this: ⋆ and 15 empty boxes.
The stars represent the six letters we pick. The empty boxes to the left of the stars provide the "padding" needed to ensure that no two adjacent letters are chosen.
Thus the answer is: in how many ways can we arrange the 6 identical pairs and the 15 identical empty boxes? The answer is ( 6 2 1 ) = 6 ⋅ 5 ⋅ 4 ⋅ 3 ⋅ 2 ⋅ 1 2 1 ⋅ 2 0 ⋅ 1 9 ⋅ 1 8 ⋅ 1 7 ⋅ 1 6 = 2 1 ⋅ 1 9 ⋅ 1 7 ⋅ 8 = 5 4 2 6 4 .
Inspiration
I thought of this problem after buying in a second-hand book store six volumes of Sue Grafton's alphabet mysteries. The store happened to have these six: "A" is for Alibi , "F" is for Fugitive , "H" is for Homicide , "K" is for Killer , "N" is for Noose , and "W" is for Wasted . I realized that none of the books were adjacent in the series. "What are the chances of that?" I thought immediately.
I calculated the 5 4 2 6 4 arrangements in my head on the way home, but calculating the odds is better done with a calculator around. The probability that six randomly chosen letters from the alphabet contain no adjacent letters is ( 6 2 6 ) ( 6 2 1 ) = 1 3 ⋅ 5 ⋅ 2 3 ⋅ 2 2 ⋅ 7 2 1 ⋅ 1 9 ⋅ 1 7 ⋅ 8 = 2 3 0 2 3 0 5 4 2 6 4 ; or reduced further, = 1 3 ⋅ 5 ⋅ 2 3 ⋅ 1 1 3 ⋅ 1 9 ⋅ 1 7 ⋅ 4 = 1 6 4 4 5 3 8 7 6 ≈ 2 3 . 6 % .
Incidentally, at this time, Grafton has not yet written "Z" is for ... , and "Y" is for Yesterday appeared so recently that one cannot reasonable expect it in a second-hand book store. This makes the odds slightly lower, about 20.2%.