Skip to content

Instantly share code, notes, and snippets.

@kthakore
Last active August 9, 2018 21:10
Show Gist options
  • Save kthakore/fa0c78e184c559f17f8e1f3e573bc031 to your computer and use it in GitHub Desktop.
Save kthakore/fa0c78e184c559f17f8e1f3e573bc031 to your computer and use it in GitHub Desktop.
README.md

Write a program given the specifications below. Use any language, google any thing you need :)

Input

Your program should expect valid JSON representing a two dimensional matrix. It will be in one of the following two formats:

A) a list of lists

The expected format is [ [variable names], [first row], [second row], ... ]

recombinator '[ ["a","b","c"], [1,2,null], [null,3,4], [5,null,6] ]'

B) a list of objects

JSON objects are simply unordered collections of key:value pairs.

Each row is represented by an object containing the variables set for that row.

Accordingly, this form of input is convenient for sparse data sets.

recombinator '[ { "a":1, "b":2 }, { "b":3, "c":4 }, { "c":6, "a":5 } ]'

Output

Your program should transform the input into a single JSON object mapping variable names to lists of values.

For input type (B), any variables that are missing in a row should be imputed with null.

The order of the values in each variable's list should be the same as the order of the rows.

'{ "a": [1,null,5], "b": [2,3,null], "c": [null,4,6] }'

Verification

  • How would you test and verify this tool?
  • Write some unit test cases for this tool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment