b_gandurov

Programming Basics Online Pre - Exam - 19 and 20 March 2022 / 06. Substitute

Mar 20th, 2022 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. k_number = int(input())
  2. l_number = int(input())
  3. m_number = int(input())
  4. n_number = int(input())
  5.  
  6. first_number_range = range(k_number, 8 + 1, 1)
  7. second_number_range = range(9, l_number - 1, -1)
  8. third_number_range = range(m_number, 8 + 1, 1)
  9. forth_number_range = range(9, n_number - 1, -1)
  10.  
  11. valid_change_count = 0
  12. available_valid_change = True
  13.  
  14. for first_number in first_number_range:
  15.     for second_number in second_number_range:
  16.  
  17.         if first_number % 2 == 0 and second_number % 2 != 0:
  18.  
  19.             for third_number in third_number_range:
  20.                 for forth_number in forth_number_range:
  21.  
  22.                     if third_number % 2 == 0 and forth_number % 2 != 0:
  23.  
  24.                         num_one = str(first_number) + str(second_number)
  25.                         num_two = str(third_number) + str(forth_number)
  26.  
  27.                         if num_one == num_two:
  28.                             if available_valid_change:
  29.                                 print("Cannot change the same player.")
  30.  
  31.                         else:
  32.                             if valid_change_count >= 6:
  33.                                 available_valid_change = False
  34.  
  35.                             if available_valid_change:
  36.                                 print(f"{first_number}{second_number} - {third_number}{forth_number}")
  37.                                 valid_change_count += 1
Add Comment
Please, Sign In to add comment