fork download
  1. from itertools import cycle
  2.  
  3. ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  4.  
  5. def main():
  6. encrypt_code = codeer('NOBODY EXPECTS THE SPANISH INQUISITION!', 'CIRCUS')
  7. print("{}".format(encrypt_code))
  8.  
  9. def codeer(tekst, sleutel):
  10. pairs = zip(tekst, cycle(sleutel))
  11. code = ""
  12.  
  13. for pair in pairs:
  14. if pair[0].isupper():
  15. total = reduce(lambda x, y: ALPHA.index(x) + ALPHA.index(y), pair)
  16. code += ALPHA[total % 26]
  17. else:
  18. code += pair[0]
  19. return code
  20.  
  21. main()
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
PWSQXQ MORYUVA VBW AGCHAUP KHIWQJKNAQV!