Advertisement
JpRuEcIQedVCHB

Untitled

Dec 30th, 2024
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. # 14b
  2.  
  3. def generate_groups(lst, n):
  4.     if not lst:
  5.         yield []
  6.     else:
  7.         for group in (((lst[0],) + xs) for xs in itertools.combinations(lst[1:], n-1)):
  8.             for groups in generate_groups([x for x in lst if x not in group], n):
  9.                 yield [group] + groups
  10.  
  11. """
  12. for s1, s2, s3 in generate_groups(range(1, 7, 1), 2):
  13.    key['steckers'] = [s1, s2, s3]
  14.    plain = cipher.decrypt(code_opgave_b, key)
  15.    plain = plain.replace("0", " ").replace("8", ",").replace("3", ".")
  16.    print(f"{s1}, {s2}, {s3} -> {plain}")
  17.  
  18. # (1, 4), (2, 3), (5, 6) -> IK KEN GEEN ANDERE LANDEN, ZELFS AL BEN IK ER GEWEEST.
  19. """
  20.  
  21. # 14c
  22.  
  23. for s1, s2, s3 in generate_groups(range(1, 7, 1), 2):
  24.     key['steckers'] = [s1, s2, s3]
  25.  
  26.     for p in itertools.permutations(range(1, 7, 1)):
  27.         key['reflector'] = p
  28.  
  29.         plain = cipher.decrypt(code_opgave_c, key)
  30.         plain = plain.replace("0", " ").replace("8", ",").replace("3", ".")
  31.         print(f"{s1}, {s2}, {s3} - {p} -> {plain}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement