In the above passcode, we mark the points 1-5-9-6-3-7.
How many combinations does Android 9 point unlock have?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
And a pattern can be anything as long as the following restrictions are observed:
He needs to have at least four points (and obviously no more than nine). -Once The point is marked can not be reused. He can use one or several "plays horse," as [0 5 4 2]. 'You can not go through a point not scored without dialing. For example, the pattern [0 2 1 4] is illegal because moving your finger between 0 and 2 mark the 1. 'Once a point is marked, can be used to reach another point unmarked. For example, [0 4 3 5] and [0 4 5 3] are valid.
With these restrictions it reaches a certain amount of points used combinations as:
4 points: 1624 combinations.
5 points: 7152 combinations.
6 points: 26016 combinations.
7 points: 72912 combinations.
8 points: 140 704 combinations.
9 points: 140 704 combinations.
Making a total of 389112 possible combinations to lock your phone.
Can you post your solution in English?
Please can you tell how you got the number of combinations in more detail
In Python:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
Here's my MATLAB code. To get the answer I just called f([],[]).
function [outputArg] = f(A,B)
outputArg=(length(A)>=4);
if isempty(A)
for i=-1:1
for j=-1:1
B=[B; i,j]; %B stores points not yet used
end
end
outputArg=4*f([1,1],B(1:8,:))+4*f([1,0],[B(1:7,:); B(9,:)])+f([0,0],[B(1:4,:); B(6:9,:)]);
elseif length(A)<9
for i=1:size(B,1)
if ~ismember((B(i,:)+A(1,:))/2,B,'rows')
outputArg=outputArg+f([B(i,:); A],[B(1:i-1,:); B(i+1:size(B,1),:)]);
end
end
end
end
Here is a solution that calculates both the total number of valid paths as well as finds the longest path. The length of a path is defined as the sum of Euclidean distances between successive dots placed on a unit grid.
from math import sqrt
from itertools import combinations, permutations
def middle_point(p, q):
return (p[0] + q[0]) // 2, (p[1] + q[1]) // 2
def distance(p, q):
return sqrt((p[0] - q[0])**2 + (p[1] - q[1])**2)
def check_path(path):
used_points = set()
prev_point = None
path_length = 0
for point in path:
if prev_point != None:
d = distance(prev_point, point)
path_length += d
if (d == 2 or d > sqrt(5)) and middle_point(prev_point, point) not in used_points:
return False, None
prev_point = point
used_points.add(point)
return True, path_length
ALL_DOTS = tuple((i, j) for i in range(-1, 2) for j in range(-1, 2))
max_length = 0
best_path = None
count = 0
for r in range(4, 10):
print("Checking paths of length", r)
for combination in combinations(ALL_DOTS, r):
for path in permutations(combination):
is_valid, length = check_path(path)
if is_valid:
count += 1
if length > max_length:
max_length = length
best_path = path
print(max_length, best_path, count, sep="\n")
C c o d e :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
If you compile and run this simple C program then you will get the solution 3 8 9 1 1 2
Problem Loading...
Note Loading...
Set Loading...
Java code:
Output: