Skip to content

Instantly share code, notes, and snippets.

@adamesque
Last active August 29, 2015 14:14
Show Gist options
  • Save adamesque/e4ae854ef7365b4c2da6 to your computer and use it in GitHub Desktop.
Save adamesque/e4ae854ef7365b4c2da6 to your computer and use it in GitHub Desktop.

The Reaction Ruby Exercise

We use this exercise to get a sense of your coding style, your judgement, and your familiarity with Ruby. There's no one right solution, so feel free to tackle the problem however you see fit.

JSON Boolean Merger App

Your task is to build a simple command-line application. This application takes a JSON array of nested objects:

[{
  "views": {
    "v1": { "access": true },
    "v2": { "access": false },
    "v3": { "access": false }
  }
},
{
  "views": {
    "v1": { "access": false },
    "v2": { "access": true },
    "v3": { "access": true },
  }
}]

It outputs a single object that contains a merged copy of the permissions where in the leaf nodes, true values should override false ones. For the input above, the application should output:

{
  "views": {
    "v1": { "access": true },
    "v2": { "access": true },
    "v3": { "access": true }
}

Assumptions

You can assume that JSON objects will only be nested 2 deep.

Requirements

Before running your application, we'll unzip/clone it into a directory on a UNIX-like system running Ruby v2 or higher, and run bundle install if a Gemfile is present.

We'll then read any README file present at the root of your repo. If there are instructions you'd like to include (like how to invoke your app), leave them there.

Your application will be run on a variety of inputs, which may include malformed data.

Submitting the exercise

Please submit a zip file or a link to a git repository containing your application and any related files (READMEs, tests, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment