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

Home > Probability
Mountain Motif (Posted on 2010-04-07) Difficulty: 2 of 5
A five digit positive integer is a mountain number if the first three digits are in strictly ascending order and the last three digits are in strictly descending order. For example, 46872 is a mountain number, but none of 43434, 54456 and 46766 is a mountain number.

Determine the probability that N is a mountain number, given that N is a positive integer chosen at random between 40000 and 99999 inclusively.

See The Solution Submitted by K Sengupta    
Rating: 3.5000 (2 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: my way | Comment 4 of 8 |
(In reply to my way by Ady TZIDON)

Taking up Ady's challenge:

The below tabulation is categorized by length of the mountain number. It first calculates up to length 17. Length 18 is calculated separately and has just one member--the upper limit specified by Ady; it does not actually fit the scheme as the peak is not in the middle, as there is no middle. The length 3 includes one not in the range Ady specified: 120.

Within each size group, the detail lines show the peak digit, the two combination values, and the product of those two combinations. The size is repeated at the bottom of the group with the total of the possibilities.

*** 3 ***
 9       8  9            72
 8       7  8            56
 7       6  7            42
 6       5  6            30
 5       4  5            20
 4       3  4            12
 3       2  3            6
 2       1  2            2
 3       240  (total for length 3, including mountain number 120)
*** 5 ***
 9       28  36          1008
 8       21  28          588
 7       15  21          315
 6       10  15          150
 5       6  10           60
 4       3  6            18
 3       1  3            3
 5       2142
*** 7 ***
 9       56  84          4704
 8       35  56          1960
 7       20  35          700
 6       10  20          200
 5       4  10            40
 4       1  4             4
 7       7608
*** 9 ***
 9       70  126         8820
 8       35  70          2450
 7       15  35          525
 6       5  15           75
 5       1  5            5
 9       11875
*** 11 ***
 9       56  126         7056
 8       21  56          1176
 7       6  21           126
 6       1  6            6
 11      8364
*** 13 ***
 9       28  84          2352
 8       7  28           196
 7       1  7            7
 13      2555
*** 15 ***
 9       8  36           288
 8       1  8            8
 15      296
*** 17 ***
 9       1  9            9
 17      9
----------------------------
 33089   (this is the total excluding 123456789876543210, but including 120)
----------------------------
 
*** 18 ***
 9       1  1            1
 18      1
 33090 
 

From this you'd subtract 1 to exclude 120, bringing us back to 33089.

Of course, you'd divide by the number of numbers of all sorts in the range, to get the probability in question, but this is the combinatorics portion.
 
 


  5   cls
 10   for Size=3 to 17 step 2
 15   print "***";Size;"***"
 20     Leadin=(Size-1)//2
 25     Tot4size=0
 30     for Peak=9 to 2 step -1
 40       C1=combi(Peak-1,Leadin):C2=combi(Peak,Leadin)
 50       Tot4size=Tot4size+C1*C2:print Peak,C1;C2,C1*C2
 60       if Leadin=Peak-1 then cancel for:goto *ReportSize
 70     next
 80   *ReportSize
 90     print:print Size,Tot4size:print
100     Tot=Tot+Tot4size
110   next Size
120   print Tot:print:print
200   Lead=8:Trail=9
210   Size=18
215   print "***";Size;"***"
225     Tot4size=0
230     for Peak=9 to 2 step -1
240       C1=combi(Peak-1,Lead):C2=combi(Peak,Trail)
250       Tot4size=Tot4size+C1*C2:print Peak,C1;C2,C1*C2
260       if Leadin=Peak-1 then cancel for:goto *ReportSize2
270     next
280   *ReportSize2
290     print:print Size,Tot4size:print
300     Tot=Tot+Tot4size
320   print Tot:print:print


  Posted by Charlie on 2010-04-08 12:10:06
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
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