Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In case someone don't know what a pattern lock is, they are like this:

example of a pattern lock

I am curious on the probability of randomly cracking one of these 'passwords', given that the length of the grid is 3x3 and that we know the pattern length (e.g number of lines).

Also, you may or not noticed but the pattern can go in both + and x directions.

Note: we can have multiple lines that go to a single dot, but we can never draw a line above another line (I think some apps allow this, but for this question lets assume we will not).

share|cite|improve this question
Can patterns be of any length (i.e., 1 or more dots)? – sacohe Dec 6 '12 at 3:26
1… – user51427 Dec 6 '12 at 3:26
@sacohe the minimum is connecting 2 dots, the maximum however, was left blank because the answers I want to be like a function that you put one number here and then everything is done using that number sorry my englishç – ajax333221 Dec 6 '12 at 3:30
Perhaps a duplicate of Combination of smartphones' pattern password. – Bill Dubuque Dec 6 '12 at 4:12
@BillDubuque I agree, after knowing the total combinations should not be hard to calculate the odds of cracking one of those – ajax333221 Dec 6 '12 at 4:15

The answer arrived at the end in sunflower's link, 389112 is actually incorrect. It doesn't take into account patterns connect via 2 steps along a line, or a peg jump if the middle point is already used. The correct answer thus becomes 766752. Here's the explanation given by Yoyo Zhou, a Google engineer, along with his algorithm :-

share|cite|improve this answer
Actually 389112 is correct. It is impossible to draw patterns like '1-8-2' since the middle dot should be also connected. (Swiping fingers like '1-8-1-2' does not help.) I too got 'incorrect' solution 766752 without considering that and got 389112 after fixed. – JiminP May 22 '14 at 11:17
'1-8-2' is not a peg jump. An example of a peg jump would be '2-1-3'. Also, though older phones initially didn't allow moves like '1-8-2', it's valid in almost all new phones now. I know for a fact that it is, in mine. – Anton Schigur May 22 '14 at 12:52
So can '1-8-2' be done without doing '1-8-5-2'? (My phone can't do this.) And the result 389112 of course concerns those moves. ('1-2-3', '2-1-3', '2-3-1' are valid and different, but '1-3-2' can't be done.) – JiminP May 22 '14 at 16:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.