andrewgilmartin / interview1 / 0.1.3


The algorithm sums the reward values found in a graph. Each node in the graph contains the reward value and a list of child nodes.



The algorithm is given a URL referencing a node in the graph. Getting the URL must respond with a JSON encoded object with "children" and "reward" properties. The children are an array of URL references to other nodes. The reward is a numeric double.

For example, the URL

might return the JSON

  "children": [ 
  "reward": 1

It is not an error if the graph repeats child nodes, but it is an error if the graph is cyclic. A repeated child node is one where a node is referenced as a child of two or more parent nodes.


The output is a single numeric double representing the sum of the rewards of all the nodes in the graph rooted at the given URL node reference.


For example, in the following replace the APIKEY with your API key (starts with "sim")

curl \
  -X POST \
  -d '""' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Simple APIKEY' \