Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
cities = {} while True: data = input() if data == "Sail": break data_split = data.split("||") city = data_split[0] population = int(data_split[1]) gold = int(data_split[2]) if city not in cities: cities[city] = {"population": population, "gold": gold} else: cities[city]["population"] += population cities[city]["gold"] += gold while True: line = input() if line == "End": break line_split = line.split("=>") command = line_split[0] city = line_split[1] if command == "Plunder": people = int(line_split[2]) gold = int(line_split[3]) cities[city]["population"] -= people cities[city]["gold"] -= gold print(f"{city} plundered! {gold} gold stolen, {people} citizens killed.") if cities[city]["population"] <= 0 or cities[city]["gold"] <= 0: del cities[city] print(f"{city} has been wiped off the map!") else: gold = int(line_split[2]) if gold < 0: print(f"Gold added cannot be a negative number!") continue else: cities[city]["gold"] += gold print(f"{gold} gold added to the city treasury. {city} now has {cities[city]['gold']} gold.") if not cities: print("Ahoy, Captain! All targets have been plundered and destroyed!") else: print(f"Ahoy, Captain! There are {len(cities)} wealthy settlements to go to:") for city, values in cities.items(): print(f"{city} -> Population: {cities[city]['population']} citizens, Gold: {cities[city]['gold']} kg")
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)