Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- treasure_chest = input().split("|")
- stolen_goods = []
- event = input().split(" ")
- while True:
- if event[0] == "Yohoho!":
- break
- if event[0] == "Loot":
- event.remove(event[0])
- for x in event:
- if x not in treasure_chest:
- treasure_chest.insert(0, x)
- elif event[0] == "Drop":
- position = int(event[1])
- if 0 <= position < len(treasure_chest) - 1:
- dropped_item = treasure_chest[position]
- treasure_chest.pop(position)
- treasure_chest.append(dropped_item)
- elif event[0] == "Steal":
- for i in range(int(event[1])):
- if len(treasure_chest) == 0:
- break
- else:
- stolen_item = treasure_chest[len(treasure_chest) - 1]
- stolen_goods.append(stolen_item)
- treasure_chest.remove(stolen_item)
- event = input().split(" ")
- stolen_goods.reverse()
- treasure_sum = 0
- counter = 0
- if len(treasure_chest) > 0:
- for chest in treasure_chest:
- treasure_sum += len(chest)
- counter += 1
- pirate_profit = treasure_sum / counter
- print(", ".join(stolen_goods))
- print(f"Average treasure gain: {pirate_profit:.2f} pirate credits.")
- else:
- print(", ".join(stolen_goods))
- print("Failed treasure hunt.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement