SHOW:
|
|
- or go back to the newest paste.
1 | # (mask, min, max) | |
2 | occ = [("?d", 0, 3), | |
3 | ("?l", 3, 5), | |
4 | ("?u", 1, 1), | |
5 | ("?s", 0, 2)] | |
6 | ||
7 | pwlen = [8, 9] | |
8 | ||
9 | from collections import OrderedDict | |
10 | ||
11 | def getMasks(occurrences, length, depth=0): | |
12 | char, min, max = occurrences.pop(0) | |
13 | char = [char] | |
14 | results = [] | |
15 | for combination in range(min, max+1): | |
16 | if not occurrences: | |
17 | results += [char*combination] | |
18 | else: | |
19 | - | results += list(map( |
19 | + | res = getMasks(occurrences[:], length-combination, depth+1) |
20 | - | lambda apx: char*combination + apx, |
20 | + | if res is not None: |
21 | - | getMasks(occurrences[:], length-combination, depth+1))) |
21 | + | results += list(map(lambda apx: char*combination + apx, res)) |
22 | - | if occurrences and not filter( |
22 | + | if occurrences and not list(filter( |
23 | - | lambda x: True if len(x) == length else False, results): |
23 | + | lambda x: True if len(x) == length else False, results)): |
24 | return None | |
25 | return results | |
26 | ||
27 | masks = [] | |
28 | ||
29 | for pwl in pwlen: | |
30 | masks += getMasks(occ[:], pwl) | |
31 | - | masks = list(filter(lambda msk: True if len(msk) in pwlen else False, masks)) |
31 | + | masks = filter(lambda msk: True if len(msk) in pwlen else False, masks) |
32 | - | masks = list(map(lambda x: "".join(x), masks)) |
32 | + | masks = map(lambda x: "".join(x), masks) |
33 | - | masks = list(OrderedDict.fromkeys(masks)) |
33 | + | masks = OrderedDict.fromkeys(masks) |
34 | ||
35 | for m in masks: | |
36 | print(m) |