Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Enumerating 4x4 "Android-like" pattern locks

a guest May 14th, 2014 180 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. validPatternQ[pattern_List, n_] :=
  2.  Module[
  3.   {k},
  4.   ! (Or @@ Table[
  5.       MemberQ[
  6.        Drop[pattern, k],
  7.        Alternatives @@ (
  8.          {{1/2, 1/2}, {1/3, 2/3}, {2/3, 1/3}}.pattern[[{k - 1, k}]])
  9.        ],
  10.       {k, 2, n}
  11.       ])
  12.   ]
  13. size = 4;
  14. points = Tuples[Range[size], 2];
  15. Sum[
  16.  {n, k} = {1000000, 0};
  17.  Do[If[validPatternQ[RandomSample[points], len], ++k], {n}];
  18.  (size^2)!/(size^2 - len)!*k/n,
  19.  {len, 4, size^2}
  20. ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top