Advertisement
UF6

1.6 Problem 1acd

UF6
Jun 28th, 2016
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.30 KB | None | 0 0
  1. alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2. print(alphabet[0])
  3. alphadick={}
  4. for i, letter in enumerate(alphabet):
  5.     alphadick[letter]=i
  6. print (alphadick)
  7. alphadick["H"]
  8. def affinecode(message,a=1,b=0):
  9.     code=""
  10.     for letter in message:
  11.         letter=letter.upper()
  12.         x = alphadick[letter]
  13.         m= (a*x+b)%26
  14.         u= alphabet [m]
  15.         code =code+u
  16.     return (code)
  17. print(affinecode("ONEWILLSELDOMGOWRONGIFONEATTRIBUTESEXTREMEACATIONSTOVANITYAVEVERAGEESTOHABITONALPETTYTOONESTFEAR",5,18))
  18. #KFMYGVVEMVHKAWKYZKFWGRKFMSJJZGXOJMEMDJZMAMSCSJGKFEJKTSFGJISTMTMZSWMMEJKBSXGJKFSVPMJJIJKKFMEJRMSZ
  19. print(affinecode("KFMYGVVEMVHKAWKYZKFWGRKFMSJJZGXOJMEMDJZMAMSCSJGKFEJKTSFGJISTMTMZSWMMEJKBSXGJKFSVPMJJIJKKFMEJRMSZ",21,18))
  20. #ONEWILLSELDOMGOWRONGIFONEATTRIBUTESEXTREMEACATIONSTOVANITYAVEVERAGEESTOHABITONALPETTYTOONESTFEAR
  21. print(affinecode("HOWDIDAFOOLANDHISMONEYGETTOGETHERINTHEFIRSTPLACE",11,18))
  22. #VYUXOXSJYYTSFXVOWMYFQGCQPPYCQPVQDOFPVQJODWPRTSEQ
  23. print(affinecode("VYUXOXSJYYTSFXVOWMYFQGCQPPYCQPVQDOFPVQJODWPRTSEQ",19,18))
  24. #HOWDIDAFOOLANDHISMONEYGETTOGETHERINTHEFIRSTPLACE
  25. print(affinecode("MOLLYSEEMSTOBEINTERCEPTINGOURMESSAGESBETH",23,12))
  26. #CWFFSKAACKHWJAOZHANGATHOZUWENCAKKMUAKJAHR
  27. print(affinecode("CWFFSKAACKHWJAOZHANGATHOZUWENCAKKMUAKJAHR",17,12))
  28. #MOLLYSEEMSTOBEINTERCEPTINGOURMESSAGESBETH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement