Company: Stripe
Difficulty: medium
Request Routing System You are building a request routing system for datacenters. The system supports commands that register datacenters, update their health, compute geographic distance, and route user requests to the nearest available healthy datacenter. Each datacenter has a unique name , a latitude , a longitude , a capacity , a health status, and a current load. A newly registered datacenter is healthy and has load 0 . The whole standard input is handed to your function as a single string containing the commands, one per line. Process them in order and return one output line per command. Supported commands ### REGISTER name latitude longitude capacity Add a datacenter. Return OK if the name is new, latitude is in [-90, 90] , longitude is in [-180, 180] , and capacity is greater than 0 ; otherwise return ERROR . A REGISTER that returns ERROR changes nothing, so the name stays free and a later REGISTER may still claim it. ### SET_HEALTHY name value Set the health of name to true or