It was only a few days until
Christmas, and Santa was dreading
all the stockings he would have to
fill. That night, he had a strange
dream. As he sat staring at a huge
pile of socks of seven different
colors (azure, beige, cabernet,
daffodil, ecru, fuschia, and gold),
the Ghost of Christmas Past
appeared and said, "If you were
to pick two socks at random, the
odds are 50:50 that you would get
a matched pair." He then waved
his hand and all the gold socks
vanished, but the Ghost stated
that the odds of getting a matched
pair were still 50:50.
He waved his hand again, and the fuschia socks vanished, but again he stated that
the odds were still 50:50.
In turn, he made the ecru, daffodil, and
cabernet socks vanish, but in each
case he said the odds of a matched
pair remained at 50:50.
At this
point, Santa counted the remaining
socks and found that he had 25
left. He asked the Ghost how many
socks he had made vanish. The
Ghost replied, "All I'll tell you is
that it is a multiple of the original
number of socks of your favorite
color."
What is Santa’s favorite
color and how many socks did the
Ghost make vanish?
clearvars,clc
for b=1:12
a=25-b;
disp([a b])
ncolor=[a b];
for next=1:9999999
ncolor(end+1)=next;
tot=sum(ncolor); t=size(ncolor);
p=0;
for match=1:length(ncolor)
p=p+ncolor(match)/tot * (ncolor(match)-1)/(tot-1);
end
if abs(p-.5)<.0000001
fprintf('%7d',flip(ncolor))
fprintf(' %15.13f\n',p)
if length(ncolor)==7
break
else
next=0;
continue
end
end
ncolor(end)=[];
end
if length(ncolor)>=7
totaldis=sum(ncolor(3:7))
for i=1:7
if mod(totaldis,ncolor(i))==0
fprintf('\n%7d %7d %7d %7d %7d %7d %7d\n',flip(ncolor))
disp([mod(totaldis,ncolor(i)) ncolor(i)])
disp('*****')
end
end
end
end
finds two scenarios that seemed to work.
In both instances, cabernet was Santa's favorite color, the last color to disappear.
The first such case is that in which the colors from gold to ecru were
1539 513 171 57 3 6 19
respectively. The total disappeared was 2283 = 1539+513+171+57+3, which is divisible by 3.
The other case was
4131 1377 459 153 51 10 15
where the total disappeared was 6171=4131+1377+459+153+51, which is divisible by 51.
However, only the latter case satisfies the condition that where the final two also exhibit the probability = 1/2 condition. Thus the ghost made 6171 socks vanish, and, again, cabernet was Santa's favorite color.
Rather than go back and put the check into the program, it was simple enough to do the check manually.
Checks on the probability of a match follow each set of remaining socks:
3 6 19 0.5000000000000
57 3 6 19 0.5000000000000
171 57 3 6 19 0.5000000000000
513 171 57 3 6 19 0.5000000000000
1539 513 171 57 3 6 19 0.5000000000000
totaldis =
2283
1539 513 171 57 3 6 19
0 3
*****
51 10 15 0.5000000000000
153 51 10 15 0.5000000000000
459 153 51 10 15 0.5000000000000
1377 459 153 51 10 15 0.5000000000000
4131 1377 459 153 51 10 15 0.5000000000000
totaldis =
6171
4131 1377 459 153 51 10 15
0 51
*****
|
Posted by Charlie
on 2024-12-03 12:37:05 |