pacho_the_python

Untitled

Feb 7th, 2022
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. treasure_list = input().split("|")
  2. sum_len = 0
  3. stolen_items = []
  4. actions = input().split(" ")
  5. while actions[0] != "Yohoho!":
  6.  
  7.     if actions[0] == "Loot":
  8.         actions.remove(actions[0])
  9.         for action in actions:
  10.             if action in treasure_list:
  11.                 pass
  12.             else:
  13.                 treasure_list.insert(0, action)
  14.  
  15.     elif actions[0] == "Drop":
  16.         index = len(treasure_list) - 1
  17.         if int(actions[1]) > index:
  18.             pass
  19.         else:
  20.             treasure = treasure_list[int(actions[1])]
  21.             treasure_list.pop(int(actions[1]))
  22.             treasure_list.append(treasure)
  23.  
  24.     elif actions[0] == "Steal":
  25.         for i in range(int(actions[1])):
  26.             if len(treasure_list) == 0:
  27.                 break
  28.             stolen_item = treasure_list[len(treasure_list) - 1]
  29.             stolen_items.append(stolen_item)
  30.             treasure_list.pop()
  31.  
  32.     actions = input().split(" ")
  33.  
  34. stolen_items.reverse()
  35. print(", ".join(stolen_items))
  36.  
  37. treasure_sum = 0
  38. counter = 0
  39. pirate_profit = 0
  40. if len(treasure_list) == 0:
  41.     print("Failed treasure hunt.")
  42. else:
  43.     for i in treasure_list:
  44.         treasure_sum += len(i)
  45.         counter += 1
  46.     pirate_profit = treasure_sum / counter
  47.     print(f"Average treasure gain: {pirate_profit:.2f} pirate credits.")
  48.  
Advertisement
Add Comment
Please, Sign In to add comment