mladrad

The Angry Cat

Jun 26th, 2024
702
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.26 KB | Source Code | 0 0
  1. items_list = list(map(int, input().split(", ")))
  2. entry_point = int(input())
  3. type_of_items = input()
  4. left_list = []
  5. right_list = []
  6. result = 0
  7. position = ''
  8. if entry_point in range(len(items_list)):
  9.     for left in range(0, entry_point):
  10.         left_list.append(items_list[left])
  11.     for right in range(entry_point + 1, len(items_list)):
  12.         right_list.append(items_list[right])
  13.  
  14.     if type_of_items == "cheap":
  15.         if min(left_list) <= min(right_list):
  16.             res = [i for i in left_list if i < items_list[entry_point]]
  17.             result = sum(res)
  18.             # result = min(left_list)
  19.             position = "Left"
  20.         else:
  21.             res = [i for i in right_list if i < items_list[entry_point]]
  22.             result = sum(res)
  23.             # result = min(right_list)
  24.             position = "Right"
  25.     elif type_of_items == "expensive":
  26.         if max(left_list) > max(right_list):
  27.             res = [i for i in left_list if i >= items_list[entry_point]]
  28.             result = sum(res)
  29.             # result = sum(left_list)
  30.             position = "Left"
  31.         else:
  32.             res = [i for i in right_list if i >= items_list[entry_point]]
  33.             result = sum(res)
  34.             position = "Right"
  35.  
  36. print(f"{position} - {result}")
  37.  
Advertisement
Add Comment
Please, Sign In to add comment