Mercurial > public > m209
comparison m209/keylist/generate.py @ 26:425981f27876
More work on generating a key list. Added some tests.
TODO: need to account for not all wheels having all the letters.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 14 Jun 2013 21:46:42 -0500 |
parents | b6b52d63cd50 |
children | 941590d946c0 |
comparison
equal
deleted
inserted
replaced
25:b6b52d63cd50 | 26:425981f27876 |
---|---|
93 ratio = num_eff / TOTAL_PINS | 93 ratio = num_eff / TOTAL_PINS |
94 | 94 |
95 if not (0.4 <= ratio <= 0.6): | 95 if not (0.4 <= ratio <= 0.6): |
96 return False | 96 return False |
97 | 97 |
98 # Check for more than 6 consecutive effective pins | 98 # Check for more than 6 consecutive effective pins on a wheel |
99 # TODO | 99 # TODO: not all letters are on every wheel |
100 | 100 |
101 # Check for more than 6 consecutive ineffective pins | 101 for pins in pin_list: |
102 # TODO | 102 run = 0 |
103 for i in range(len(pins) - 1): | |
104 if ord(pins[i]) + 1 == ord(pins[i + 1]): | |
105 run = 2 if run == 0 else run + 1 | |
106 else: | |
107 run = 0 | |
108 if run >= 7: | |
109 return False | |
110 | |
111 # Check for more than 6 consecutive ineffective pins on a wheel | |
112 # TODO: not all letters are on every wheel | |
113 | |
114 for pins in pin_list: | |
115 x = 'A' | |
116 for y in pins: | |
117 if ord(y) - ord(x) >= 8: | |
118 return False | |
119 x = y | |
103 | 120 |
104 return True | 121 return True |