Edgardo
Dec30-11, 05:45 PM
My answer for f_2(n) is wrong by a factor of 2. It should be f_2(n)=4(n-1)(2n-1). That is if you count e.g. the paths (5,8) and (8,5) as two different paths. This makes sense if you interpret the paths as code for your smartphone.
With 5 and 8 I mean dots in the following scheme:
0 1 2
3 4 5
6 7 8
As an example I printed the possible codes for a 9 dot lock. The codes consist of 2 dots.
>>> ================================ RESTART ================================
>>>
[0, 1]
[0, 3]
[0, 4]
number of paths starting with dot 0 is: 3
[1, 0]
[1, 2]
[1, 3]
[1, 4]
[1, 5]
number of paths starting with dot 1 is: 5
[2, 1]
[2, 4]
[2, 5]
number of paths starting with dot 2 is: 3
[3, 0]
[3, 1]
[3, 4]
[3, 7]
[3, 6]
number of paths starting with dot 3 is: 5
[4, 0]
[4, 1]
[4, 2]
[4, 3]
[4, 5]
[4, 6]
[4, 7]
[4, 8]
number of paths starting with dot 4 is: 8
[5, 2]
[5, 1]
[5, 4]
[5, 7]
[5, 8]
number of paths starting with dot 5 is: 5
[6, 3]
[6, 4]
[6, 7]
number of paths starting with dot 6 is: 3
[7, 6]
[7, 3]
[7, 4]
[7, 5]
[7, 8]
number of paths starting with dot 7 is: 5
[8, 7]
[8, 4]
[8, 5]
number of paths starting with dot 8 is: 3
solution (totals paths): 40
I also tried to calculate f_3(n), i.e. the number of possible paths consisting of 3 dots. Here is my result:
For n \geq 3 I get: f_3(n)=8(11 - 18n + 7n^2).
This formula does not apply for n=2 since less path configurations are possible (e.g. you don't have the horizontal path (0,1,2) in a n*n =2*2 dot-square).
For a n*n=3*3 dot-square the formula gives: f_3(3)=160
I also wrote a Python program to check this result:
>>> ================================ RESTART ================================
>>>
[0, 1, 2]
[0, 1, 3]
[0, 1, 4]
[0, 1, 5]
[0, 3, 1]
[0, 3, 4]
[0, 3, 7]
[0, 3, 6]
[0, 4, 1]
[0, 4, 2]
[0, 4, 3]
[0, 4, 5]
[0, 4, 6]
[0, 4, 7]
[0, 4, 8]
number of paths starting with dot 0 is: 15
[1, 0, 3]
[1, 0, 4]
[1, 2, 4]
[1, 2, 5]
[1, 3, 0]
[1, 3, 4]
[1, 3, 7]
[1, 3, 6]
[1, 4, 0]
[1, 4, 2]
[1, 4, 3]
[1, 4, 5]
[1, 4, 6]
[1, 4, 7]
[1, 4, 8]
[1, 5, 2]
[1, 5, 4]
[1, 5, 7]
[1, 5, 8]
number of paths starting with dot 1 is: 19
[2, 1, 0]
[2, 1, 3]
[2, 1, 4]
[2, 1, 5]
[2, 4, 0]
[2, 4, 1]
[2, 4, 3]
[2, 4, 5]
[2, 4, 6]
[2, 4, 7]
[2, 4, 8]
[2, 5, 1]
[2, 5, 4]
[2, 5, 7]
[2, 5, 8]
number of paths starting with dot 2 is: 15
[3, 0, 1]
[3, 0, 4]
[3, 1, 0]
[3, 1, 2]
[3, 1, 4]
[3, 1, 5]
[3, 4, 0]
[3, 4, 1]
[3, 4, 2]
[3, 4, 5]
[3, 4, 6]
[3, 4, 7]
[3, 4, 8]
[3, 7, 6]
[3, 7, 4]
[3, 7, 5]
[3, 7, 8]
[3, 6, 4]
[3, 6, 7]
number of paths starting with dot 3 is: 19
[4, 0, 1]
[4, 0, 3]
[4, 1, 0]
[4, 1, 2]
[4, 1, 3]
[4, 1, 5]
[4, 2, 1]
[4, 2, 5]
[4, 3, 0]
[4, 3, 1]
[4, 3, 7]
[4, 3, 6]
[4, 5, 2]
[4, 5, 1]
[4, 5, 7]
[4, 5, 8]
[4, 6, 3]
[4, 6, 7]
[4, 7, 6]
[4, 7, 3]
[4, 7, 5]
[4, 7, 8]
[4, 8, 7]
[4, 8, 5]
number of paths starting with dot 4 is: 24
[5, 2, 1]
[5, 2, 4]
[5, 1, 0]
[5, 1, 2]
[5, 1, 3]
[5, 1, 4]
[5, 4, 0]
[5, 4, 1]
[5, 4, 2]
[5, 4, 3]
[5, 4, 6]
[5, 4, 7]
[5, 4, 8]
[5, 7, 6]
[5, 7, 3]
[5, 7, 4]
[5, 7, 8]
[5, 8, 7]
[5, 8, 4]
number of paths starting with dot 5 is: 19
[6, 3, 0]
[6, 3, 1]
[6, 3, 4]
[6, 3, 7]
[6, 4, 0]
[6, 4, 1]
[6, 4, 2]
[6, 4, 3]
[6, 4, 5]
[6, 4, 7]
[6, 4, 8]
[6, 7, 3]
[6, 7, 4]
[6, 7, 5]
[6, 7, 8]
number of paths starting with dot 6 is: 15
[7, 6, 3]
[7, 6, 4]
[7, 3, 0]
[7, 3, 1]
[7, 3, 4]
[7, 3, 6]
[7, 4, 0]
[7, 4, 1]
[7, 4, 2]
[7, 4, 3]
[7, 4, 5]
[7, 4, 6]
[7, 4, 8]
[7, 5, 2]
[7, 5, 1]
[7, 5, 4]
[7, 5, 8]
[7, 8, 4]
[7, 8, 5]
number of paths starting with dot 7 is: 19
[8, 7, 6]
[8, 7, 3]
[8, 7, 4]
[8, 7, 5]
[8, 4, 0]
[8, 4, 1]
[8, 4, 2]
[8, 4, 3]
[8, 4, 5]
[8, 4, 6]
[8, 4, 7]
[8, 5, 2]
[8, 5, 1]
[8, 5, 4]
[8, 5, 7]
number of paths starting with dot 8 is: 15
solution (totals paths): 160
>>>
So, for a 9 dot lock the probability of guessing the correct code is 1/160.
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.