Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. def decoder(new_list, split_list):
  2. password = ""
  3. for string in new_list:
  4. for pair in split_list:
  5. if string == pair[0]:
  6. print(string, "STRING")
  7. print(pair, "PAIR")
  8. password += pair[1] + " "
  9. return password
  10.  
  11. def dice_roll(num):
  12. rolls = [[random.randint(1, 6) for i in range(5)] for i in range(num)]
  13. return rolls
  14.  
  15. def format_rolls(rolls):
  16. new_list = []
  17. for roll in rolls:
  18. formatted_rolls = ""
  19. for num in roll:
  20. formatted_rolls += str(num)
  21. new_list.append(formatted_rolls)
  22. return new_list
  23.  
  24. def file_open():
  25. with open("codes.txt", "r") as codes:
  26. line_list = codes.read().splitlines()
  27. split_list = (item.split("t") for item in line_list)
  28. return split_list
  29.  
  30. def decoder(new_list, split_list):
  31. password = ""
  32. for string in new_list:
  33. for pair in split_list:
  34. if string == pair[0]:
  35. print(string, "STRING")
  36. print(pair, "PAIR")
  37. password += pair[1] + " "
  38. return password
  39.  
  40. if __name__ == "__main__":
  41. print("Your new password is:",
  42. decoder(format_rolls(dice_roll(int(input("Number of words: ")))),
  43. file_open()))
  44.  
  45. 11122 able
  46. 11123 abnormal
  47. 11124 abrasion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement