Skip to content

Instantly share code, notes, and snippets.

@nwallace
Last active September 24, 2018 14:24
Show Gist options
  • Save nwallace/f7c0475b97f90b8117b6153d2bc73618 to your computer and use it in GitHub Desktop.
Save nwallace/f7c0475b97f90b8117b6153d2bc73618 to your computer and use it in GitHub Desktop.

We'd like you to complete this small coding exercise. You can use any programming language you like for the implementation. We've tried to keep it small so that it doesn't take too much time. Be pragmatic, but do enough to demonstrate your expertise in domain modeling and testing.

You don't need to persist any data to disk.

Please email us a tarball (tar -czvf your-code.tgz your-code-dir/) or gitbundle (GIT_DIR=your-code-dir/.git git bundle create your-code.gitbundle --all) at least a day before our interview, and include a README explaining the design of your solution and your thought process behind it. We'll review your code before we meet, and then we'll talk about it and extend it during the interview.

If you have any questions, please email us: Nathan Wallace (nmw@secondgen.com) and Nick Wagner (nwagner@secondgen.com).

Problem Statement:

Let's write some code to track purchase history for people.

Your code should process a structured input file (e.g. ruby mycode.rb input.txt or python mycode.py input.txt, etc) and print out a small report about the input to the console.

Each line of the input file will begin with a command. There are two possible commands: PRODUCT and ORDER.

The PRODUCT command registers a new product to the app, providing its name and unit price. For example:

PRODUCT Domain 35.95

This line registers a product called "Domain" which cost $35.95 each.

The ORDER command registers a new order in the app, providing the date of its placement and which products it contains and their quantities. For example:

ORDER 20170201 Domain 1

indicates an order placed on Feb 1, 2017 containing 1 Domain, while this line:

ORDER 20161231 Domain 3 EmailAccount 4

indicates an order placed on Dec 31, 2016 containing 3 Domains and 4 EmailAccounts.

Discard any orders whose dates are before January 1, 2000

Generate a report containing each product, the number of product items sold, and the product's revenue (rounded to the nearest cent). Order your results by the number of items sold, highest to lowest.

Example input:

PRODUCT Domain 20.00
PRODUCT EmailAccount 60.00
PRODUCT Website 35.00
ORDER 19890509 Domain 2 Website 1 EmailAccount 1
ORDER 20150325 Domain 1 Website 1
ORDER 20150809 Domain 2
ORDER 20160714 EmailAccount 2

Example output:

Domain: 3 sold for $60.00
EmailAccount: 2 sold for $120.00
Website: 1 sold for $35.00

Thank you!

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