Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can Predict your response with '90%' accuracy.

Status
Not open for further replies.

SidYuca

Technical User
Nov 13, 2008
79
MX
I Enjoyed this thread and thought that I'd contribute.

1. Multiply 2 single digits to form a product
2. Continue to multiply the resulting product by a single digit of your choice until said product is 7 digits (or more in length)
3. Circle one of the non-zero digits of the product (for me to guess) and post the remaining digits in any order.
4. I will post your circled digit..

Two questions: How? and give a mathematically valid reason for % accuracy.

 
My last post got truncated for some reason. Here is the end of the list:

1382976 6 2 0 4
1389150 1 4 2 3
1399680 7 7 1 0
1406250 1 2 7 0
1411200 7 2 2 2
1417176 3 11 0 0
1417500 2 4 4 1
1428840 3 6 1 2
1440000 8 2 4 0
1451520 9 4 1 1
1458000 4 6 3 0
1469664 5 8 0 1
1474560 15 2 1 0
1476225 0 10 2 0
1481760 5 3 1 3
1488375 0 5 3 2
1492992 11 6 0 0
 
@ Karluk, Thanks for your last. One thing you did not say but seems apparent from your results (and your goals). To achieve a number as low as 882 you must have been limiting the factors of 3 at the outset. True?

**********************************************
What's most important is that you realise ... There is no spoon.
 
kwbMitel said:
To achieve a number as low as 882 you must have been limiting the factors of 3 at the outset. True?
No, there is no limitation at all on any of the exponents, except (of course) that the exponents can't be so large as to generate a number that is bigger than seven digits. Frankly, I don't see how you could have arrived at any other conclusion. Taking a look at the subset < 1,499,999 I've actually printed, the biggest exponent of three that appears is 3^12. The only reason that 3^13 doesn't make an appearance in the list is that 3^13 = 1,594,323, which is higher than the upper limit of the subset.

So, unless someone finds an error in my list, the raw data proves that the person guessing the missing digit can't achieve a 90% success rate without doing something to bamboozle the person generating the clue into doing something that generates an unusually large number of numbers that are divisible by nine.
 
karluk
I am an not a trained coder so please excuse errors in my comments...but in your code reproduced below you have..
count=0.0
sample=1000000
for x in xrange(sample):
result=random.randint(1,9)
while len(str(result))<7:
result=result*random.randint(1,9)
if result%9==0:
count +=1
print count/sample*100

r.e. " while len(str(result))<7:"
Doesn't that restrict you to MAX 6 DIGITS when problem called for 7???? PLUS does your language when changing a number to a string consider the leading space for the sighn. I believe this MAY just UP your data points.

You also Said:
" The only reason that 3^13 doesn't make an appearance in the list is that 3^13 = 1,594,323, which is higher than the upper limit of the subset."

But this too is INCORRECT it is NOT higher than te upper limit. It has 7 digits and exactly meets the problem requirements.

Please try your program with this line:

while len(str(result))< eight OR NINE:

One last point. My question:
"Do EACH of these 882 contain the 4 primes i.e. 2 and 3 and 5 and 7?"

Elisited this response from you:

"Of course not. There is no requirement in the clue construction process to make sure that the product includes all the primes 2, 3, 5, 7. The only requirement is that no larger prime be allowed."

I asked the question because of YOUR statement"
"I arrived at my numbers by brute force calculation. There are a total of 882 numbers between 1,000,000 and 9,999,999 whose prime factorization involves only the primes 2, 3, 5, 7."
"Of course" you can see how your words above may have prompted my question.

I look forward to your revised numbers if they are waranted.
 
@SidYuca - The code you question was posted by IPGuru, not karluk.

==> The only reason that 3^13 doesn't make an appearance in the list is that 3^13 = 1,594,323, which is higher than the upper limit of the subset.

But this too is INCORRECT it is NOT higher than te upper limit.

karluk was quite clear that for space reasons, he was only posting the 128 numbers between 1,000,000 to 1,499,999. He as not posting all 882 numbers between 1,000,000 and 9,999,999.

==> "Do EACH of these 882 contain the 4 primes i.e. 2 and 3 and 5 and 7?"
"Of course not. There is no requirement in the clue construction process to make sure that the product includes all the primes 2, 3, 5, 7. The only requirement is that no larger prime be allowed."

karluk's answer is completely correct, and no revised numbers are necessary. The problem calls for only those products that can be obtained by using single digit multipliers. Every single digit multiplier can be obtained through the 4 single digit primes 2, 3, 5, and 7; therefore, every valid multiplier for the puzzle can be obtained by using multipliers of these four primes.
2 = 2
3 = 3
4 = 2 * 2
5 = 5
6 = 3 * 2
7 = 7
8 = 2 * 2 * 2
9 = 3 * 3
That means that every valid product of single digit multiplication can be obtained by using zero or multiples of these four primes. The reason that "no" is the correct answer to your question is because not every prime has to be used. The very first posted number 1,000,000 does not contain primes 3 or 7. It obtained by repetitive multiplications of just 2 and 5.


--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
Wise men speak because they have something to say, fools because they have to say something. - Plato
 
Mine was a question and not an implication that 4 primes had to be used. The question was initiated by the last HIS statement:
"I arrived at my numbers by brute force calculation. There are a total of 882 numbers between 1,000,000 and 9,999,999 whose prime factorization involves only the primes 2, 3, 5, 7."

That statements says "whose prime factorization involves only the primes 2, 3, 5, 7." I point out "involves only the primes 2, 3, 5, 7" It didnot say "involves some combination of the primes 2, 3, 5, 7." nor did it include any 'and/ors" It was this ambiguity
that initiated my question not the problem.

I know that you or strongman are among the guys who can give the mathematical proof.

I hope IPGuru reads my comment above r.e. <7. Thanks

 
==> That statements says "whose prime factorization involves only the primes 2, 3, 5, 7." I point out "involves only the primes 2, 3, 5, 7" It didnot say "involves some combination of the primes 2, 3, 5, 7." nor did it include any 'and/ors" It was this ambiguity
I think the point here is that any number arrived by the terms of the problem, i.e.

1. Multiply 2 single digits to form a product
2. Continue to multiply the resulting product by a single digit of your choice until said product is 7 digits (or more in length)

will be one which only involves the primes 2, 3, 5, and 7. In other words, there is no product (P) that you can achieve within the context of the problem which is not a product of 2, 3, 5, and 7.
P = a2[sup]i[/sup] * b3[sup]j[/sup] * c5[sup]k[/sup] * d7[sup]l[/sup]
where all four coefficients (a, b, c, d) >= 0 and all four exponents (i, j, k, l) >= 0.
Given that, it's trivial to use brute force to obtain every possible seven digit product that can be calculated given the rules of the problem. If you think that's not the case, then please present a value which cannot be obtained by just these four primes.

--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
Wise men speak because they have something to say, fools because they have to say something. - Plato
 
CajunCenturion,
* I am well aware of the unique prime factorization theorem.

* I am well aware that cobinations of the primes <10 must be used.

What I wasn't aware of if the person who said:

"whose prime factorization involves only the primes 2, 3, 5, 7."

realized that the words HE USED could be interpreted that ALL 4 must be used because it lacks the words "some combination of" or the use the words 'and/or' between the primes. Did I make a sin by asking for clarification? Pardon me if I did.
 
==> realized that the words HE USED could be interpreted that ALL 4 must be used because it lacks the words
Ok. I thought his response of "There is no requirement in the clue construction process to make sure that the product includes all the primes 2, 3, 5, 7." (emphasis mine) cleared that up for me.

Sorry to have gotten involved.



--------------
Good Luck
To get the most from your Tek-Tips experience, please read
FAQ181-2886
Wise men speak because they have something to say, fools because they have to say something. - Plato
 
as to the discusion on my programm

1st
while len(str(result) <7

the leading sign is not counted in this (at least not in python)
for counts of 6 digits or less another multiplication happens, the loop only exits when result is 7 more more digits (which can be demonstrated by printing result & this point.
one the loop exits result is checked to see if it is a multiple of 9

playing with this code it becomes apparent that the longer the final result the greater the chance of getting a +ve. 3 digits would be enough to meet KBMitels 50% requirement.


Computers are like Air conditioners:-
Both stop working when you open Windows
 
SidYuca said:
I hope IPGuru reads my comment above r.e. <7.
I've never programmed in Python, but if the while loop works the same in Python as in other languages, IPGuru's code won't exit until it generates a seven-digit number. He keeps on multiplying by randomly generated one digit numbers as long as his partial product is < 7. Once it becomes 7 digits long, the loop condition turns false and he exits. So far, so good.

So IPGuru's product is most likely seven digits long. But I doubt that he can generate every single valid seven digit candidate number using his code. Consider, for example, 5^10 = 9,765,625. The only way to generate this number is if IPGuru's code generates consecutive powers of five - 5, 25, 125, etc. But 5^8 = 390,625 and multiplying by one more power of five gives the seven digit number 5^9 = 1,953,125. The fact that the product is now seven digits long will cause IPGuru's loop to exit, and he will never consider 5^10 as a valid candidate number. So my guess is that IPGuru's code will generate some, but not all, of the valid seven digit candidates.
 
Incidently, the examples of 5^9 and 5^10 illustrate extremely clearly why multiplying by randomly selected single digit numbers is such a terrible way to get a representative cross-section of the 882 seven-digit candidate numbers. A reasonable selection process should result in a 1 out of 882 chance that each possible seven digit number should be selected. But 5^9 will be selected if, and only if, five happens to pop up nine consecutive times when selecting randomly from the digits 2, 3, ..., 9. The chances of nine consecutive fives appearing is only 1/8^9, or one chance in 134,217,728. So, the chance of seeing 5^9 using this supposedly "fair" selection method is less than 1 in a hundred million, not the correct 1 in 882. No wonder multiples of nine are overly represented by this awful selection process! And that's not even calculating the odds of seeing 5^10, which is less than one in a billion!
 
No wonder multiples of nine are overly represented by this awful selection process!

Yes, agreed, but to someone unfamiliar with the process or the probabilities, the answer seems almost magical.

I'm missing something in generating the 882 numbers as I would think the number needs to be much higher. But, it doesn't matter what I think does it? 882 seems incredibly low but the good news is that it simplifies figuring out the probabilities.

**********************************************
What's most important is that you realise ... There is no spoon.
 
Karluk
1. Think of this as a math exam and not a review process for putting a math book to press. The problem IS the problem, the selection process is integral. I learned a long time ago not to shoot the messenger, Of course you are always free do rewrite the message but then it is not the same message.

2. While len(NumString) < 7 still puzzles me. (At least in VB)

What is the length of the following integers when changed to strings.

len(Str(100))
len(Str(1))
len(Str(123456))

In VB6 the answers are: 4,2,7


What is the difference between the followimg two statements (if any)

1. While len(NumString) < 7
2. While len(NumString) <= 7

will both loop run through to completion with these strings
"1234567"

Does "less than" mean the same as "less than or equal"


kwbMitel 882
I think that you are thinking that there are a million multiples of 9 between 1 milliom and 10million but are not considering that many of those contain larger prime factors than 7 (eventh though they may or may not include the ones permitted by the problem,

I still look for a statistical mathematical proof from somebody.
 
I offer the surprising answer of 98.46% for the problem and this somewhat unusual approach which I solicit your constructive critique.

First I make this conservative assumption. The average number picked fro the set 2-9 is ‘5’ and because 5^8 <7 digits and 5^9 = 7 digits I will go with the 8 to be on the conservative side. So I will pick only 8 random digits from (2-9)
The 5 digits 2,4,5,7,8 are Bad for me, while 9 is Great and 3 and 6 are each half great.
To rectify the half greats I will duplicate the entire set and obtain:
10 Bad numbers, each of which I will place in a Black hollow ball.
Each of the two nines will go into a White hollow ball.
While the 4 half-greats will be divided between 2 other White Balls.
I feel that I have not contaminated the distribution/mix to this point.

So it looks like the problem boils down to a combinatory problem of (n/r) where n=14 and r = 8 where order is not important and repetition is permitted.

Formula: n!/r!(n-r)! Yields 3003 possible combinations. Of these only 45 consist of only 8 Bs. The rest contains from 1 to 4 W’s.

I was lazy with the math so went to And plugged in the data, Generated the list, cut and pasted into MS Word and did 4 searches (Note the W,s were always placed to the far right) one each on:
B,W} …………….. 380
B,W,W}…………..1260
B,W,W,W }………1008
B,W,W,W,W }…… 209
Total…………….. 2957
A search on {b,b,b,b,b,b,b,b,} yield the remaining 45

2957/3003 = 98.46% approx

Someone else can do the math on the W’s. The solution won’t make the book but will generate chatter.
 
sidyuka
Python does not include any leading sign when coverting numbers to strings, as such:

len(str(100))
3
len (str(1))
1
len(str(123456))
7
also while <=7 will also iterate the loop when the length of the result is 7 characters meaning it will one exit untill 8 digits.

this is not an attempt to shoot the messenger & I appreciate your feedback - it did make me check the simulation again just to make sure it was working as I expected.
if you are interested further you could download python & give it a try (I assume you are on windows as you refer to VB, python is already installed on most linux distros)I find it a remarkably god prototyping language



cc the purpose of my program was not to test every possible permutation achievable with this process, but to try & give a real world simulation of the process.



Computers are like Air conditioners:-
Both stop working when you open Windows
 
Sid, from a VB coder, < 7 will continue the loop while the number is less than 7 digits. Once it hits seven digits, it will exit the loop. <= 7 will allow the loop to exit when at least an eight digit number is generated.

Look at the results generated from the following (very quickly generated code):
Code:
Sub GetLength(intIn As Integer)

Dim i As Long

i = 1
Dim strInt As String

Do While Len(strInt) < 7
i = i * intIn
strInt = CStr(i)
Loop
Debug.Print "1 - " & i
End Sub

Sub GetLength2(intIn As Integer)

Dim i As Long

i = 1
Dim strInt As String

Do While Len(strInt) <= 7
i = i * intIn
strInt = CStr(i)
Loop
Debug.Print "2 - " & i

End Sub

Sub runtests()
Dim i As Integer
For i = 1 To 8
GetLength (i + 1)
GetLength2 (i + 1)
Next i
They are:
Code:
1 - 1048576
2 - 16777216
1 - 1594323
2 - 14348907
1 - 1048576
2 - 16777216
1 - 1953125
2 - 48828125
1 - 1679616
2 - 10077696
1 - 5764801
2 - 40353607
1 - 2097152
2 - 16777216
1 - 4782969
2 - 43046721

Also, you will have the leading space reserved if you use the Str() function in VB. If you use the CStr() function then the leading space will not be reserved.

Hope that helps with the question on the VB side of things [smile]

Andy
---------------------------------
Zebracorn: 50% Zebra, 50% Unicorn = 100% Real.

 
while trying to check all possible values I have noticed some errors in earlier posts.

there are actually less than 882 valid 7 digit numbers as some of these are only achievable from a 7 digit predecessor.
I make it 810 Valid numbers with 557 Divisible by 9 which gives 69% (after rounding)
as this is significantly different to the emulation approach I an currently checking my code to see if I have made any errors.



Computers are like Air conditioners:-
Both stop working when you open Windows
 
Thank you for the help on the while loop, I appreciate it.

Let me ask you what would happen under the following hypothetical situation using < 7 in the loop

I am building a prime factorization using combos of 2,3,5,7 and get to the 7 digit number 1,048,576 (2^20) or somewhere near this by using other permitted primes. Now, we don't know if the 1,048,576 was generated by 20 twos or some combo or 2s, 4s or 8s, but if it was generated by powers of 2's would 2^21 ever get IN that loop to be counted as a potential?

2^20 which is the

 
IPGuru
I think my last post may explain away your newly found 'predecessor problem' IF you are generating your numbers from primes. In your coding if you get to (near) 1/2 million (the predecessor called x) you DO want to include 2x,3x,4x,5x,6x,7x,8x as well as 9x because at that predecessor point of x the user is permitted to select any of the numbers 2-9.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top