Google Answers Logo
View Question
 
Q: Derangements of socks ( No Answer,   2 Comments )
Question  
Subject: Derangements of socks
Category: Science > Math
Asked by: gnuspeak-ga
List Price: $25.00
Posted: 20 May 2005 12:07 PDT
Expires: 21 May 2005 09:03 PDT
Question ID: 523799
How many ways are there to distribute n distinct pairs of socks to n
people so that no two people have a matching pair of socks?  The real
difficulty here is that the right and left socks are not considered
distinct.  If a person has the blue left sock and red right sock, this
is considered the same as if they have the red left sock and the blue
right sock.  I can not figure out how to compensate for this and thus
I am always over-counting.  Any help?  Even a partial solution would
help put my mind at rest.  However, do not bother telling me how to do
it with right and left socks (or as the "letters into the wrong
envelopes" problem), as I already understand the solution to that
problem.

Request for Question Clarification by pafalafa-ga on 20 May 2005 14:18 PDT
Are the people considered distinct?

That is, if person A gets one red and one blue sock, and person B gets
a blue and a green sock, is this the same (or different) than if A
gets blue/green, and B gets red/blue?

Clarification of Question by gnuspeak-ga on 20 May 2005 15:47 PDT
Yes, the people are distinct.  I also realize that I should explain
that each of the five people is given two socks.

Clarification of Question by gnuspeak-ga on 20 May 2005 15:50 PDT
Whoops, I meant each of the n people.
The point is, everyone has a pair of socks, but none of the pairs are
matching pairs.

Clarification of Question by gnuspeak-ga on 20 May 2005 17:05 PDT
By brute force, I solved this for n=3 and got 6.  Also, I believe the
answer for n=4 to be 90.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Derangements of socks
From: mathtalk-ga on 20 May 2005 21:28 PDT
 
Here is a partial solution of the problem.  For background on derangements:

[Derangements -- MathWorld, A Wolfram Web Resource]
http://mathworld.wolfram.com/Derangement.html

We can introduce an artificial distinction between the first and
second color (sock) assigned to each person, then switch the first and
second colors for certain persons so that the first socks form a
permutation of the n colors and the second socks a derangement of
those.

Counting such configurations leads to an overcount of the
distinguishable configurations of socks (where the two colors are an
unordered pair for each person) by at least a factor of two, for one
can switch the first and second sock for all persons simultaneously
and get a configuration that is different in the artificial sense
taken here but the same in the sense posed by gnuspeak-ga.

An exact count would be obtained in this fashion if we were to
partition the derangements according to the number of cycles therein. 
We illustrate this for the cases of n = 3 and n = 4.

With n = 3 there are only two derangements and both are single cycles
of length 3.  Therefore with the artificial distinction of a first row
socks which is one permutation and a second row which is a derangement
of the first row, we count:

   3! * !3  =  6*2  = 12

But switching the two socks of the first person forces a switch in the
two socks of every person, to preserve the permutation-ness of the
first row, because the derangement in the second is the whole cycle. 
Thus 12/2 = 6 is the count for n = 3 without regard to the socks'
order.  A diagram of the artificial configurations is this, where the
top row contains "first" socks and the bottom row the "second" socks:

R  G  B    R  G  B
G  B  R    B  R  G

G  B  R    G  B  R
R  G  B    B  R  G

B  R  G    B  R  G
R  G  B    G  B  R

R  B  G    R  B  G
G  R  B    B  G  R

G  R  B    G  R  B
R  B  G    B  G  R

B  G  R    B  G  R
R  B  G    G  R  B

[Note that these configurations pair off by switching the top and bottom row.]

If we apply this to the case n = 4, we discover that there are n! = 24
possibilities for the top row and !n = 9 respective possibilities for
the bottom row, which suggests an answer of 24*9/2 = 108.  But this is
an overestimate, because not every derangment with n = 4 is a whole
cycle of length 4.

In fact the nine derangements with n = 4 may be classified as six that
are cycles of length 4 and three that are a pair of transpositions
(cycles of length 2).  The calculation must then be corrected to
divide by 2 for the derangements that contain a single cycle and by 4
for those which have two cycles:

  4! * (6/2 + 3/4) = 24*(3 + 3/4) = 72 + 18 = 90

as gnuspeak-ga has claimed.

In an extended set of notes on counting techniques, here:

[Notes on counting, by Peter J. Cameron]
http://www.maths.qmw.ac.uk/~pjc/notes/counting.pdf

it is noted that the number of derangements of n items containing a
single cycle is simply (n-1)!, as may be seen (pg. 33) by writing the
first element followed by the remaining n-1 elements in any order as a
cycle.

For smallish values of n it is not difficult to classify the
derangements by the number of cycles contained.  The cycle to which
the the first element belongs must, if not of length n, be of length
n-2 or less (since leaving a cycle of length 1 is tantamount to a
fixed point).  Hence one can quickly build up a small table that
counts the number of derangements of n things containing m cycles by
recursion:

  \    # containing m cycles
n  \    1     2     3     4    
-----------------------------
 2 |    1     0     0     0 
 3 |    2     0     0     0 
 4 |    6     3     0     0 
 5 |   24    20     0     0 
 6 |  120   130    15     0 
 7 |  720   924   210     0

We illustrate the extension to n = 7.  There are !7 = round(7!/e) =
1854 derangements in all, and we begin by counting how many have
exactly two cycles.  The first element must belong to a cycle of
length 2,3,4, or 5, leaving a cycle of complementary length 5,4,3, or
2.  There are 6 possible subsets of size two that would contain the
first element, C(6,2) = 15 possible subsets of size three containing
the first element, C(6,3) = 20 of size four and C(6,4) = 15 of size
five.  Applying the numbers of derangements for cycles of these
smaller sizes:

  # derangements of 7 items containing 2 cycles =     6 *  1 * 24
                                                   + 15 *  2 *  6
                                                   + 20 *  6 *  2
                                                   + 15 * 24 *  1
                                = 924

Likewise the cycle containing the first element could of length 2 or 3
and leave room for two more cycles:

  # derangements of 7 items containing 3 cycles =    6 * 1 * 20
                                                  + 15 * 2 *  3
                                = 210

Finally no choice of length for the cycle containing the first element
allow an additional three cycles, so it is not possible for a
derangement of 7 items to contain 4 or more cycles.  [There are
however 7*15 = 105 derangements of 8 items containing 4 cycles
(transpositions).]


regards, mathtalk-ga
Subject: Re: Derangements of socks
From: gnuspeak-ga on 21 May 2005 09:03 PDT
 
Thank you mathtalk-ga for your excellent analysis.  Breaking the
distributions into cycles is the sort of insight I was looking for.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy