Showing posts with label combinatorics. Show all posts
Showing posts with label combinatorics. Show all posts

Saturday, January 9, 2016

[OlymLSec_20160109CBDR] Derangement of Cars in a Roundabout

Problem / Question

Introduction
     Some enthusiastic student posted this “deranged” question on Facebook.  It is taken from the Singapore Math Kangaroo Contest.  The question involves derangements, which does not appear in any syllabus in Singapore before university level.
     If the problem involved a circular permutation, the correct answer would have been  (5 – 1)! = 4 × 3 × 2 × 1 = 24.  But this is not a circular permutation, because the roads are distinguished by their different positions.  If one rotates the roundabout, this would be considered a different pattern.  If it were a permutation, the answer would have been  5! = 5 × 4 × 3 × 2 × 1 = 120.  However, it is not a permutation, because the cars cannot go back to their original road in the opposite direction.  That is what the Kangaroo phrase “drives less than one round” mean.
     A derangement is a some rearrangement in which things are not allowed to go back to their original position.  If one has not learned the formula for derangements, how could this be solved?

Strategy
     We can consider simpler cases [H10] of the problem and build up the answer from there.  We may also split the problem into two cases.  [H11]


Solution

     Let  !n  denote the number of derangements if there are  n  cars and  n  road branches in the roundabout.  [This is called the subfactorial of  n.]

     For  n = 1,  !n = 0  because the car has no way but to go back on the original road.

     For  n = 2,  !n = 1  because the only way is for the two cars to swap.

     For  n = 3:  Car  #1  has two choices: either road  #2  or road  #3.  But it cannot end up swapping roads with any car, else the remaining car would have to go back to its original road, which is not allowed.  So it is either  #1 ® #2 ® #3 ® #1  or  #1 ® #3 ® #2 ® #1.  Therefore  !3 = 2.

     For  n = 4:  Car  #1  has 3 choices.  For each of these choices, either it ends up (1) swapping roads with the other car, or  (2) it does not swap.  
Case (1):  If it swaps with the other car, then the remaining  2  cars will have  !2 = 1 way.
Case (2):  If car  #1  goes to some road but not swapping roads with it,  then the other  3  cars will have  !3 = 2  ways to choose roads different from their original roads.
Therefore  !4 = 3 × (!3 + !2) = 3 × (2 + 1) = 9.

     For  n = 5:  Car  #1  has 4 choices.
Case (1):  It swaps with the other car.  The remaining  3  cars will have  !3 = 2 ways.
Case (2):  It does not swap with any car.  The other  4  cars will have  !4 = 9  ways.
Therefore  !5 = 4 × (!4 + !3) = 4 × (9 + 2) = 44.

Ans:  (B)  44.

Remarks
     For more information regarding derangements, please refer to here and here.

H02. Use a diagram / model   (can be used for small number cases)
H03. Make a systematic list   (can be used for small number cases)
H04. Look for pattern(s)
H05. Work backwards
H09. Restate the problem in another way
H10. Simplify the problem
H11. Solve part of the problem

Suitable Levels
* Lower Secondary Mathematics Competition
* University / College Combinatorics
* other syllabuses that involve derangements
* any precocious or interested learner who is interested






Sunday, November 8, 2015

[H2_ACJC2015P2Q7] Choosing balls by another method

Question


Introduction
     This question is taken from a Junior College examination in Singapore.  It looks deceptively simple.  Actually, there is an easy way to solve it.  But reading the question made me do a double take.  Since we are choosing a maximum of  4  balls for a given colour and balls of the same colour are indistinguishable, why bother having  6  balls?  It turns out that as long as we have  4  balls or more for each colour, the number of balls would not matter.  So this issue is a distractor.
     I shall explain my standard approach to solving this type of problem.  I present a solution in which part (iii) is solved via a case-by-case analysis.  I suspected that there is a short cut that avoids case-by-case analysis and I finally found a short cut by a flash of inspiration.  So I shall also present the short cut to part (iii).

My Approach
     When there are repeated indistinguishable objects, I imagine objects of the same type being stacked up in columns.  For part (i) of our problem, see the diagram on the left.  I am just choosing  4  columns out of  5  (indicated by the up arrows).  Once I have chosen the columns, I just take one ball out from each column and put it into my selection.  Imagine putting them into a plastic bag – the order of the balls does not matter.  The number of ways to do this is  5C4 = 5.

For part (ii), see the diagram on the right.  First I choose one of the 5 columns and automatically take three balls (it does not matter which three actually) from that column.  From the remaining 4 columns, I choose one and pick out one of the balls from that column.  I can do this in  5 × 4 = 20 ways.  I call the pattern in part (i) “{XYZW}” (all different colours) and the pattern in part (ii) “{XXXY}” (three of one colour and another one of a different colour).  The curly brackets are a reminder that the order does not matter.   For part (iii), we can work out the other patterns and total up the number of ways.


Solution 1

(i)    Number of ways = 5C4 = 5.

(ii)   Number of ways = 5 × 4 = 20.

(iii) 
Pattern
Working
Number
{XXXX}
5C1  [5 columns, choose 1]
5
{XXXY}
done in part (ii)
20
{XXYY}
5C2  [5 columns, choose 2]
10
{XXYZ}
5 × 4C2  [5 ways for X, 4C2 ways for YZ]
30
{XYZW}
done in part (i)
5

Total =
70
             Number of ways = 5 + 20 + 10 + 30 + 5 = 70


Remarks
     Don’t you hate case-by-case analysis?  After thinking for a while, I found a short cut.  This requires thinking of a related problem.  Let us say, for example, we choose  2  orange balls,  1  green ball and  1  blue ball.  This is equivalent to throwing  4  grey (AmE. gray) balls with  2  of them going into a bin for marked “orange”,  1  into a bin marked “green”  and  1  into a bin marked “blue”.  There are  5  bins, one corresponding to each colour and they are separated by  4  grey separators (one less than the number of bins).  The number of grey balls in each bin indicates the number of balls of the respective colour chosen.  The aforementioned configuration can be codified as a string of symbols consisting of two dots followed by two separators, then a dot, a separator, a dot, and finally a separator.  Every balls-and-bins configuration can thus be codified as a string of consisting of 4 grey dots (representing 4 grey balls) and 4 separators. 

     Because of this one-to-one correspondence, the number of ways of choosing  4  coloured balls is exactly the same as the number of strings of symbols.  There are 8 symbols (4  dots and 4 separators).  Of the 8 positions for the symbols, we need to choose  4  to put in the dots.  The rest will, of course, be filled by separators.  That means  8C4 , which is  70.

Short-cut for part (iii)
     Number of ways = 4+4C4 = 70.

I hope you have learned something useful.   J


H02. Use a diagram / model
H03. Make a systematic list
H04. Look for pattern(s)
H08. Make suppositions
H09. Restate the problem in another way
H10. Simplify the problem
H11. Solve part of the problem
H12* Think of a related problem


Suitable Levels
* ‘A’ Level H2 Mathematics (» Grade 11 / 12)
* IB Mathematics SL and HL (Binomial coefficients, counting principles)
* other syllabuses that involve combinatorics (combinations and selections)
* whoever is interested







Monday, April 6, 2015

[H2PCRP20150406] Colouring The Pentagon (Combinatorics)



Introduction
     This is a question suitable for the mainstream Junior College students taking H2 mathematics, but is some primary school olympiad question from somewhere.  Whatever!  Mathematics is for everybody, young and old.  Anybody can solve this problem if  s/he makes observations and uses the right approach and thinking skills.

An Incisive Insight
     Although this pentagon is not a regular pentagon, the colouring scheme depends just on the order of colours on the edges.  We can start from one edge and see what colours are possible.  And then we can rotate the colouring scheme around.  [ We are breaking down and simplifying the problem. ] 
     Fiddling around with various possibilities, you might realise that:-
·  you cannot have three of the same colour going round the pentagon
·  you cannot have three sets of pairs of edges with the same colour.
·  you cannot two single colours and one double colour
There must be one single colour and two pairs of doubled colours.  All colouring schemes will have a  “12123”  colouring pattern going around in a loop.  The diagram below shows an example where colour 1 = yellow (Y), colour 2 = red (R)  and colour 3 = blue (B).


Do we need to consider a “21213”  pattern?  If  “12123”= “YRYRB”, we can later reassign colours, swapping R and Y to give 1=R and 2=Y and then “12123”=“RYRYB”.  So we have got that covered.  Let us worry about the reassignment later. 

Solution
     Observe that the position of the “3” (the single colour) can be rotated round the edges of the pentagon in  5  ways.

     Observe also that there are  3! = 3 ´ 2 ´ 1 = 6  ways to shuffle the colours i.e. assign colours 1, 2 and 3  to  Y, R and B.

The above two processes (rotation and shuffling) are independent of each other.  Rotation of the single colour can be done with or without the shuffling of colours.  Hence we can use the Multiplication Principle and calculate
          the total number of ways = 5 ´ 6 = 30.
Tada!

H02. Use a diagram / model
H04. Look for pattern(s)
H09. Restate the problem in another way
H10. Simplify the problem
H11. Solve part of the problem

Suitable Levels
* GCE ‘A’ Level H2 Mathematics
* IB Mathematics HL / SL
* Primary School Maths Olympiad
* other syllabuses that include combinatorics

Monday, April 23, 2012

JCCDQBHWHCB037(ii) Combinatorics : Grouping and Insertion Method




Introduction

     This question is from a source that does not credit the original source.  In the original question was poorly worded.  It did not have the words “the letters of the word”.  Instead of “each vowel must be separated”, it said “a vowel must be separated”, which is might mean there is just one such instance.  This is ambiguous.  I have taken the liberty to rephrase some parts of the question to make its meaning clearer.  In this article, I shall discuss only part (ii) of this question.

Stage 1:  Understanding the question

What is the given in the problem?  Can you organise the information?
     Though not absolutely necessary, it is helpful to draw a diagram that separate the letters into vowels and consonants and write the stack up the same letters in columns.




     There are  5  vowels (of which  O is repeated)  and  6  consonants (of which  N  and  S  are repeated).

Can you explain the problem in your own words?
     The letters of the word ‘CONNOISSEUR’ are re-arranged, which means that all the 11 letters are used.  Each vowel must be separated from another with exactly one consonant, which means that the letters must contain the pattern  “v c v c v c v c v” (where v = vowel, c = consonant).  Important: Note that the question does not say that the first letter must be a consonant.



Stage 2:  Planning

Have you seen a similar problem before?
     Yes, but this looks a bit more challenging.  There are more possibilities as first letter need not be a consonant.

What heuristics can you try?
     ·  Solve part of the problem
     ·  Split the problem into smaller problems

What topic-specific tactics can you try?
     The “v c v c v c v c v” pattern can be treated as a group (Grouping Method).  Since there are six consonants, there are two more “c”s (consonants) in the full pattern.  This looks like a problem that can use the Insertion Method.

Stage 3:  Execution



The number of ways to insert the group = 3C1 = 3
     [these are the patterns “ccvcvcvcvcv”, “cvcvcvcvcvc” and “vcvcvcvcvcc”  ]

For each pattern,
     the vowels can be arranged in  5! / 2!  ways (division because there are 2 ‘O’)
     the consonants can be arranged in  6! / 2! 2!  ways (division because of 2 ‘N’ and 2 ‘S’)

Hence the total number of ways is


Stage 4:  Evaluation

Is the answer correct?
     Yes, the answer is correct.



Stage 5:  Reflection

What have we learned by solving this problem?
     We have learned once again that heuristics and metacognition are useful in solving mathematical problems.  Specifically, we have used the following heuristics:-
          ·  Drawing a diagram
          ·  Solve part of the problem
          ·  Split the problem into smaller problems

     We have also used the following techniques that are useful for combinatorical problems:-
          ·  Grouping Method
          ·  Insertion Method
          ·  Division Method (for dealing with repeated letters)

     It is also important to understand the problem correctly and not make unfounded assumptions.  If the wording is not clear, you may want to rephrase it.




Friday, April 6, 2012

JCCDQBHWHCB014 Combinatorics : Permutations & Multiplication Principle



Suggested Approach and Solution:-

     Since the order is important, we use permutations (which are just multiplications) instead of combinations.  No over-counting or division is involved.

 

The guys can be chosen and arranged in 10P3 = 10 x 9 x 8 = 720 ways.
The gals can be chosen and arranged in 6P3 = 6 x 5 x 4 = 120 ways.
Total number of ways = 720 x 120 = 86 400 ways.

JCCDQBHWHCB009(ii) Combinatorics : Case-by-case Analysis (Addition Principle)



Suggested Approach and Solution:-

     For questions with special conditions, a good approach is to consider to the special conditions first.  It matters whether the last digit is a ‘3’ or not.  This is a complication that is handled by a Case-by-case Analysis and then totaling up the number of possibilities.

Case 1: 3 is the last digit

 

If 3 is the last digit, we have 1 choice (i.e. Hobson’s choice) for the last digit.  The first digit must be either a 1 or a 5 i.e. 2 choices.  The remaining 5 digits can be filled in  5P5 = 5!
= 5 x 4 x 3 x 2 x 1 = 120  ways.
Number of ways for this case = 2 x 5! = 240 ways.

Case 2: 3 is not the last digit

 

In this case, the last digit must be either a 1 or a 5 i.e. 2 choices.  Because these digits only occur once, the first digit will definitely be different from the last digit.  So we need not worry about the first-digit condition as it is automatically satisfied.  The front 6 digits can be filled in
          6! / 2! = 360
We divide by 2! because the digit 3 is definitely repeated.
Number of ways for this case = 2 x 360 = 720 ways.

The total number of ways = 240 + 720 = 960.




JCCDQBHWHCB007(ii) Combinatorics : “Choose, then Automatically fill” technique



     The question says “the captain must stand between the two youngest players” which I interpret literally to mean: not necessarily directly next to each other, but there can be intervening players.  Although I suspect that the one who set this question might have meant that the captain is supposed to be in between directly next to the two youngest players, I shall attempt the question according to its prima facie meaning.  Later, I shall consider what if the captain and two youngest players are together next to one another with the captain in the middle.

Suggested Approach and Solution:-


 

Number of rows to choose from = 2

The condition that “the captain must stand between the two youngest players” seems difficult, because there can be one or more intervening players.  Generally we do not favour complicated case-by-case analyses.  The good news is that we can use a “choose, then automatically fill” technique to tackle this.  Within the row with the captain, there are 5 positions and we choose 3 of them.  Then we automatically fill them with a youngest player, the captain and then the other youngest player.  The number of ways to do this is  5C3 = 10.

Number of ways the two youngest players can swap around = 2!.
Number of ways the rest of the players can shuffle around   = 7!.

Total number of ways = 2 x 5C3 x 2! x 7! = 201 600.



What if …
     What if the captain is in between directly next to the two youngest players?
 

Number of rows to choose from = 2

     If the captain is in between and directly beside the two youngest players, we treat these 3 players as a unit.  There are 3C1 = 3 ways to position this group within the row.  Note that within this group, the two youngest players can still swap around while the captain stays in their middle.  Everything else is the same as above.

Total number of ways = 2 x 3C1 x 2! x 7! = 60 480.


JCCDQBHWHCB007(i) Combinatorics : Choosing with special conditions



     This sort of question has appeared in the GCE ‘A’ levels before.  For questions with special conditions, a good approach is to consider to the special conditions first.

Suggested Approach and Solution:-
 

Number of ways to choose the young player = 2C1 = 2
The captain must be in, so two vacancies have been taken up and there are 3 left.  These places must be filled from the 7 eligible other players (excluding the captain and the two youngest players).  There are   7C3 = 35  ways to do this.  The total number of ways is
          35 x 2 = 70

JCCDQBHWHCB015 Combinatorics : Conditional Over-counting



Introduction

     This question is particularly challenging, because it does not conform to any of the usual types of problems taught at ‘A’ level.  However, we can still use the following problem solving heuristics:-
     · drawing a diagram
     · considering a simpler problem first

Suggested Approach and Solution:-

     Consider first the case for 3 couples and draw a diagram with arrows.

Suggested Approach and Solution:-

     We use the same problem-solving tactics as for question 11.  Consider first the case for 3 couples and draw a diagram with arrows.

 

We now discover that this problem is a little more complicated than that of question 11. 
Each of the 3 men has arrows coming out to 2 x 3 – 2 = 4 persons (everyone except himself and his wife).  So there are 3 x (2 x 3 – 2) = 12 arrows.  There is double-counting (arrows in both directions), but only among the men.  So we need to subtract the number of lines connecting i.e.
3C2 = 3 pairs of men.  Thus for the case of 3 couples, the calculation is:
          3 x (2 x 3 – 2) – 3C2 = 12 – 3 = 9
We verify by counting from the diagram that this is correct.

For 13 couples, we have
          13 x (2 x 13 – 2) – 13C2 = 247 ways.
         
FYI, the general formula is
          n x (2n – 2) – nC2

JCCDQBHWHCB011(i) Combinatorics : Uniform Over-counting (Division Principle)



     [ As an ice-breaker game, this is stupid!  Anyway … ]

Suggested Approach and Solution:-

     If the problem seems difficult, try a simpler problem first.  This is a useful heuristic / tactic, especially for permutation and combination problems.  Let’s say there are only six students.  Draw a diagram (a heuristic) with dots representing students, and arrows from each dot to other dots except the two dots beside it.  You will soon realize that each arrows goes in two directions.  This means there is over-counting by a factor of 2.  Whatever answer you get by counting the arrows forward must be divided by 2.


 

How many arrows are there?  (Heuristic: Think of an equivalent problem).  For each of the 6 dots, there are 6 – 3 = 3 arrows coming out (minus 3 because excluding itself and two beside it).
So the number of arrows is 6 x (6 – 3) = 18.  But we don’t really care about the direction of the arrows.  Because of the double-counting (and this is uniformly true for every pair of arrows), we must now divide this answer by 2 to get 9.  We can verify by counting from the diagram that this answer is correct.

Another approach: there are 6C2 = 15 possible line segments (connections between two dots).  But we don’t count those on the perimeter of the hexagon, so we subtract 6 (because there are six sides all round the hexagon).  This gives 15 – 6 = 9.

For 17 students, the answer is: 17 x (17 – 3) / 2 = 119