Your question is Graph Traversal Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Guardian Life models dependencies between internal services as a directed graph. Given a starting service and a destination service, determine whether the destination is reachable by following one-way dependency edges.
Implement can_reach(graph, start, target) using breadth-first search or depth-first search. The graph is represented as an adjacency list, where each key is a service name and its value is a list of directly dependent services. Return true if target can be reached from start, including when both names are the same. Return false when no path exists.
graph, a dictionary mapping strings to lists of strings; start and target, service-name strings.start to target.def can_reach(graph, start, target):