Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 14b
- def generate_groups(lst, n):
- if not lst:
- yield []
- else:
- for group in (((lst[0],) + xs) for xs in itertools.combinations(lst[1:], n-1)):
- for groups in generate_groups([x for x in lst if x not in group], n):
- yield [group] + groups
- """
- for s1, s2, s3 in generate_groups(range(1, 7, 1), 2):
- key['steckers'] = [s1, s2, s3]
- plain = cipher.decrypt(code_opgave_b, key)
- plain = plain.replace("0", " ").replace("8", ",").replace("3", ".")
- print(f"{s1}, {s2}, {s3} -> {plain}")
- # (1, 4), (2, 3), (5, 6) -> IK KEN GEEN ANDERE LANDEN, ZELFS AL BEN IK ER GEWEEST.
- """
- # 14c
- for s1, s2, s3 in generate_groups(range(1, 7, 1), 2):
- key['steckers'] = [s1, s2, s3]
- for p in itertools.permutations(range(1, 7, 1)):
- key['reflector'] = p
- plain = cipher.decrypt(code_opgave_c, key)
- plain = plain.replace("0", " ").replace("8", ",").replace("3", ".")
- print(f"{s1}, {s2}, {s3} - {p} -> {plain}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement