NumPy allowed · plain Python earns 10 bonus points
Implement cycle detection in a wait-for graph, the real, standard technique for detecting deadlock among agents holding and requesting shared resources.
Implement has_deadlock(wait_for). wait_for[a] lists the agents that agent a is waiting on. Return True if the directed graph contains ANY cycle (a deadlock), else False. Use DFS with recursion-stack tracking.
has_deadlock(wait_for: dict[str, list[str]]) -> bool