Android's lock screen feature allows people to protect their phones by joining points on a grid to make a pattern. Let be the size of the longest possible length of the pattern that can be drawn on an android phone with a pattern lock. If the grid is spaced equally by one unit what is rounded to the nearest integer?
The rules for drawing a pattern are:
You can only use a point once
You cannot "jump" a point if it is in between the two points and is part of the line that satisfies the first two points. Ie You cannot go from 1 to 9 without also hitting 5. But you can go directly from 2 to 9 without including any other point.
ONCE a point is "taken", it may THEN be skipped. A point cannot be skipped "in transit" only if it hasn't already been taken.
To fully understand the rules, it is best to try them out on a real phone.
Details and Assumptions
The points are equally spaced vertically and horizontally by one unit.
If it had been a grid, would be .
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.
Here is a solution in python 3.4: