Defend the Kingdom

Winning entry at the Infineon Technologies hackathon: a resource-dispatch simulation over a changing road graph, written and hardened in six hours.

Solution design and implementation in a team of three. Also built an agentic bug hunter for the event’s second track.

Model it as events on a clock

Attacks, mining completions and refills are events in one priority queue. The simulation always jumps to the next event, so it never wastes time on empty seconds.

Shortest path on the roads as they are

Dijkstra from the attacked clan gives the travel time to every mine in one pass.

Count everything that delays a delivery

For each mine: time until it is free, mining time for the amount needed, travel there and back, and whether it must refill first.

Greedy dispatch

Send the request to the mine with the earliest delivery. Partial deliveries earn partial gold, so a nearly empty mine can still be worth using.

Parse the input exactly

An expression parser written from scratch, because the input format was part of the test.