[quote_box_center]This is a real example, recounted in details on a forum[/quote_box_center]

Intro: My wife constantly strives to make me screw up: set the alarm for 3:00 AM, change the ringtone, removed the sync settings, removed she’s messages and then proves that she didn’t wrote that.
Joking aside, at some point i decided, “Enough!” – And put the graphical password on my android device.

0_b493d_61ead533_L.jpg[1]__1412834283_89.28.59.217[1]

The wife laughed and said that she will pick up. I laughed in response, and went on. Now she was thinking how to pick it up, but me which is the probability of this event.

The first and logical idea was to come up with a mathematical way of calculating combinations.
For this it’s necessary to specify the initial conditions:

  • Direction is important,
  • Each point could be passed only once,
  • To connect the two points they need to be in direct line of sight. I mean the first could be united with the second but not with the third.
  • Number of points: from 5 to 9. Will call it one stroke, one connection – a hop. This means, we may have from 4 to 8 hops.

Attempts to calculate options mathematically have failed. As imposed condition didn’t allowed to reveal the rules.

The next step: overkill. No that i was hoping to sort out all the tens of thousands of options. The basic idea was – to find patterns. I spent a few hours drawing diagrams. But all laws rested on the symmetry and the fact that all corners are equivalent, as well as all intermediate (except the central).

0_b4943_9f7b4240_XL.png[1]__1412842185_89.28.59.217[1]

0_b4a61_813bb28_XL.png[1]__1412842237_89.28.59.217[1]

But when we are scared of difficulties? I began still with one hop.

0_b493f_a1a250c_XL.jpg[1]__1412842331_89.28.59.217[1]

1 hop – easy as pie – 56 options
2 hop – nothing complicated – 320 options
3 hop – had to work hard – 1624 version
4 hop – it was, huh, tedious – 7152 version
5 hops – Mamma Mia, and torn hair – the result is unknown.

Then i decided not to force my brain and remember the long forgotten programming.
Uncovered Turbo Pascal, blew the dust from the variables and begat to develop the algorithm.

After 4 years of pause, a simple script on Bash took me a whole evening to debug the program. Nothing, that the algorithm was born in 20 minutes.

turbo pascal technozed.com

Here’s the output of options for each number of hops. As you can see, from 1 to 4 the numbers coincides with the practical calculations, but when the number of hops is more than 8 – there is no way, that is logical.

0_b4e12_855e3db0_XL.png[1]

Pascal has a limit of 64 KB on the size of the array. Therefore, even an array of Byte of a few tens of thousands of items is not possible. To bother with dynamic memory allocation or the records i didn’t want, so i could count the ways in details up to 4 hops:

0_b4946_c14c6c17_XL.png[1]

UPDATE. When calculating the above wasn’t considered to pass through a used point. In the new version the bug is fixed.

This is the result of sequence: 11-22-31-32-12:

0_b4e13_de89c978_XL.png[1]

And the long-awaited result:

0_b4e0e_47321e0d_XL.png[1]

So, we have 389488 options. Even if we eliminate from them 50% of the perverse choices, that no every person deprived of schizophrenia, will be able to score the first try, remains 194744 options.

0_b4948_d7e60dd4_L.png[1]

Android gives 20 attempts, after which locks the phone.

Thus, 20/194744 = ,0001 That is the probability of 0.01% !

“Well, well” – I said to my wife, showing the calculations. “Well, well” – said my wife, showing the unlocked phone.

0_b493c_6069019e_XL.jpg[1]

So, which is the lesson learned today? Yes. Keep your phone locked with a password not with a graphical one as the glass screens could easy reveal you.
Take a look at this article on How to keep your Phone Secured.

Leave a Reply