Scenario
I am using pattern matching lockscreen and I sadly forgot my pattern. I would like to know how much time I will need to unlock it. Here are the specifications of Google's lock screen, that we will use for this challenge.
- Every 5 wrong code, the user has to wait
30 seconds
before any further entry. A pattern must, at least, consist in
4 points
(see below)A point can be only used once, but you can go over it several times (see image right below):
Here, the center point is only used once, even if we go over it again for this particular pattern.
Hypothesis & Facts
We'll assume we're superheroes and that we can draw any pattern in 1 second
, we never need to eat or sleep. Yeah, we're superhumans.
I'm a very unlucky person. "Worst case scenario" is my daily life so the pattern I will attempt last will be the right one.
What do we have to pwn?
For those who don't know it, Android (and other phones now) offers the ability of unlocking the phone through drawing a pattern on a 9-point matrix. This matrix can be described as follow :
C(A) M(B) C(C)
M(D) X(E) M(F)
C(G) M(H) C(I)
- C standing for "corner point"
- M for "middle point"
- X for "center point"
- I have given identifiers to the points to make it easier
The permitted direct connections are as follows :
Corner point :
Middle point :
Center point :
However, as pointed out by steveverrill, "once the centre has been used (and therefore becomes unavailable) a direct connection between the bottom left and top right corner becomes unambiguous and therefore possible". Same goes for every "middle point", if e.g. the point B has already been counted, then a direct connection between A and C is possible. If e.g. F has already been counted, then a direct connection between C and I is possible. Etc...
Rules
- The point of this challenge is to return how much time (in human readable form, aka year/day/month/hour/whatever the time you find) I will need to unlock this damn phone.
- You can't hardcode the number of possible valid patterns (don't even Google it, you fool), calculate it (that's actually the fun part, isn't it ?)
- Shortest piece of code wins
- Good luck !