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