impressive_i

Знаки в сумме 7+7+7+7+7+7 = 7

Aug 8th, 2024
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. def get_sum(list_of_char, number):
  2.     s = 0
  3.     for ch in list_of_char:
  4.         s += int(ch + str(number))
  5.     return s
  6. '''
  7. list_of_char = ['+','+','+','+','+','+']
  8. number = 7
  9. print(get_sum(list_of_char, number))
  10. '''
  11. def  brute_force():
  12.     number = 7
  13.     list_of_oper = ['+','-']
  14.     list_of_char = []
  15.     for ch_1 in list_of_oper:
  16.         for ch_2 in list_of_oper:
  17.             for ch_3 in list_of_oper:
  18.                 for ch_4 in list_of_oper:
  19.                     for ch_5 in list_of_oper:
  20.                         for ch_6 in list_of_oper:
  21.                             list_of_char.extend([ch_1, ch_2, ch_3, ch_4, ch_5, ch_6])
  22.        
  23.                             print('Результат: ',get_sum(list_of_char, number))
  24.                             list_of_char = []
  25. brute_force()
Advertisement
Add Comment
Please, Sign In to add comment