Browse code

Fixed typo in program Added combination script

Puskás Zoltán authored on 04/02/2012 23:27:00
Showing 2 changed files

1 1
new file mode 100755
... ...
@@ -0,0 +1,32 @@
1
+#!/usr/bin/python
2
+#
3
+# Android unlock pattern combinations script
4
+# Copyright (c) 2012 Zoltan Puskas
5
+# All rights reserved.
6
+#
7
+# This program is free software and redistributred under the 3-clause BSD
8
+# license. For details see attached license file COPYING
9
+#
10
+# Maintainer: Zoltan Puskas <zoltan@sinustrom.info>
11
+# Created on: 2012.02.03.
12
+#
13
+
14
+import os
15
+
16
+# conbination generator function
17
+def combination_iter(elements, length):
18
+    for i in xrange(len(elements)):
19
+        if length == 1:
20
+            yield (elements[i],)
21
+        else:
22
+            for next in combination_iter(elements[i+1:len(elements)], length-1):
23
+                yield (elements[i],) + next
24
+
25
+# function get combinations for a set of elements				
26
+def combination(l, k):
27
+    return list(combination_iter(l, k))
28
+
29
+# for all valid ranges of points calculate dot choices
30
+for num in range(4, 10):
31
+	print "If choosing %i dots out of 9 the number of different choices is %i " % (num, len(combination(range(1, 10), num)))
32
+	
... ...
@@ -442,7 +442,7 @@ void print_summary(const struct tree_node * const root_node)
442 442
     count_valid_patterns(root_node, pattern_count, 0);
443 443
 
444 444
     for (i = 0; i < MAX_POINTS; i++) {
445
-        printf("Number of patterns for lenght %d: %d\t\
445
+        printf("Number of patterns for length %d: %d\t\
446 446
                 Minutes to bruteforce*: %d\n",
447 447
                 i+1, pattern_count[i], pattern_count[i]/5);
448 448
         sum += pattern_count[i];