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

Home > Probability
Only two digits (Posted on 2023-07-14) Difficulty: 3 of 5
Choosing randomly two integer numbers from 10 to 1,000,000 inclusive,
What are the chances they will be represented:
a. each by two distinct digits, albeit different
for each one of the numbers e.g. 322 and 78778
b.exactly the same two, like 3334 and 433344
or
c. distinct couples, sharing one digit like 5558 and 88338

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution | Comment 4 of 5 |
There are 999,991 numbers in the range, and the square of this is the denominator of each pair's probability, as the same number could be in both choices.

clearvars,clc
pairCt=zeros(10,10);
for n=10:1000000
  ns=unique(char(string(n)));
  if length(ns)==2
    s1=str2double(ns(1))+1;
    s2=str2double(ns(2))+1;   
    pairCt(s1,s2)=pairCt(s1,s2)+1;
  end
end
pairCt

builds and displays the number (ways) of each such pair combinations:

low  \       high digit
digit \      1     2     3     4     5     6     7     8     9
 0     0    58    57    57    57    57    57    57    57    57
 1     0     0   114   114   114   114   114   114   114   114
 2     0     0     0   114   114   114   114   114   114   114
 3     0     0     0     0   114   114   114   114   114   114
 4     0     0     0     0     0   114   114   114   114   114
 5     0     0     0     0     0     0   114   114   114   114
 6     0     0     0     0     0     0     0   114   114   114
 7     0     0     0     0     0     0     0     0   114   114
 8     0     0     0     0     0     0     0     0     0   114
 9     0     0     0     0     0     0     0     0     0     0
 
Then this table is utilized by

allNos=1000000-10+1;
parta=0; partb=0; partc=0;
for a=0:8
  s1=a+1;
  for b=a+1:9
    s2=b+1;
    partb=partb+pairCt(s1,s2)^2;
    for x=0:8
      s3=x+1;
      for y=x+1:9
        s4=y+1;
        u=unique([a b x y]);
        if length(u)==4
          parta=parta+pairCt(s1,s2)*pairCt(s3,s4);
        end
        if length(u)==3
          partc=partc+pairCt(s1,s2)*pairCt(s3,s4);
        end
      end
    end
  end
end
parta=sym(parta)/allNos^2
partb=sym(partb)/allNos^2
partc=sym(partc)/allNos^2
parta=eval(parta)
partb=eval(partb)
partc=eval(partc)
parta=1/(parta)
partb=1/(partb)
partc=1/(partc)

which multiplies the ways of the first chosen number by the ways of the second.

Numbers are chosen in both directions and so do not need to be doubled; when they are the same, of course, they are counted once.

The results are:

Exact probabilities:

parta =
13106352/999982000081

partb =
497212/999982000081

partc =
7722360/999982000081

Decimal:

parta =
      1.31065879175209e-05
partb =
      4.97220949936824e-07
partc =
      7.72249900435656e-06
      
Reciprocal (i.e., 1 in ...)
      
parta =
          76297.5082678231
partb =
          2011178.33053305
partc =
          129491.761596325
          

  Posted by Charlie on 2023-07-14 11:56:35
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 (0)
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