Your question is Print Simple Objects With Cycles. 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.
Tipalti debugging tools need a deterministic utility that can print a simple object graph. Each object has public properties whose values are JSON primitives or references to other simple objects. Implement a serializer that expands each object once, sorts properties alphabetically, and represents later references, including cycles, as @object_id.
The function should return a string rather than writing directly to standard output so callers can log or test the result.
Implement print_simple_object(graph, root):
graph is a dictionary mapping unique object IDs to property dictionaries.{"$ref": object_id}.root is the ID of an object in graph.{key: value, ...}.null use JSON-compatible lowercase spellings.@object_id. This includes both shared references and back-edges in cycles.def print_simple_object(graph, root):