Advertisement
SomeBody_Aplle

Untitled

Jul 14th, 2023
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. import random
  2.  
  3. line_symbol = '1234567890-=qwertyuiop[]asdfghjkl;zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'
  4.  
  5.  
  6. def random_hex():
  7. result = ""
  8. for i in range(16):
  9. result += line_symbol[random.randint(0, len(line_symbol) - 1)]
  10. return result
  11.  
  12.  
  13. CHAR_HEX = {
  14. 'а': random_hex(),
  15. 'б': random_hex(),
  16. 'в': random_hex(),
  17. 'г': random_hex(),
  18. 'д': random_hex(),
  19. 'е': random_hex(),
  20. 'ё': random_hex(),
  21. 'ж': random_hex(),
  22. 'з': random_hex(),
  23. 'и': random_hex(),
  24. 'й': random_hex(),
  25. 'к': random_hex(),
  26. 'л': random_hex(),
  27. 'м': random_hex(),
  28. 'н': random_hex(),
  29. 'о': random_hex(),
  30. 'п': random_hex(),
  31. 'р': random_hex(),
  32. 'с': random_hex(),
  33. 'т': random_hex(),
  34. 'у': random_hex(),
  35. 'ф': random_hex(),
  36. 'х': random_hex(),
  37. 'ц': random_hex(),
  38. 'ч': random_hex(),
  39. 'ш': random_hex(),
  40. 'щ': random_hex(),
  41. 'ъ': random_hex(),
  42. 'ы': random_hex(),
  43. 'ь': random_hex(),
  44. 'э': random_hex(),
  45. 'ю': random_hex(),
  46. 'я': random_hex(),
  47. ' ': random_hex(),
  48. '1': random_hex(),
  49. '2': random_hex(),
  50. '3': random_hex(),
  51. '4': random_hex(),
  52. '5': random_hex(),
  53. '6': random_hex(),
  54. '7': random_hex(),
  55. '8': random_hex(),
  56. '9': random_hex(),
  57. '0': random_hex(),
  58. }
  59.  
  60.  
  61. def complite_to_hex(line):
  62. result = ""
  63. for char in str(line):
  64. result += CHAR_HEX.get(char)
  65. return result
  66.  
  67.  
  68. def value_for_dict(item):
  69. for key, value in CHAR_HEX.items():
  70. if value == item:
  71. return key
  72. return None
  73.  
  74.  
  75. def decode_hex(line):
  76. list_items = list(line)
  77. symbol = ''
  78. result = ''
  79. for index in range(len(list_items)):
  80. symbol += line[index]
  81. if len(symbol) == 16:
  82. result += value_for_dict(symbol)
  83. symbol = ''
  84. return result
  85.  
  86.  
  87. input_string = "привет приветствую"
  88. hex_result = complite_to_hex(input_string)
  89.  
  90.  
  91. # print(hex_result)
  92. # print(decode_hex(hex_result))
  93.  
  94. def distribute_price(amount, num):
  95. if not num:
  96. return []
  97. amount = int(decode_hex(amount))
  98. return [amount // num] * num, float(f'0.{str(amount / num).split(".")[1]}') * num
  99.  
  100.  
  101. total_amount = complite_to_hex(100000000000)
  102. total_people = 101
  103. total, seven = distribute_price(total_amount, total_people)
  104. print(total, seven)
  105. print(seven / 24)
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement