- Problem
- Input Dataset
- Instructions
- Output
- Tips on getting an interview
- Instructions to submit your solution
- Questions?
Imagine you are a data engineer working for an online pharmacy. You are asked to generate a list of all drugs, the total number of UNIQUE individuals who prescribed the medication, and the total drug cost, which must be listed in descending order based on the total drug cost and if there is a tie, drug name.
Disclosure: The projects that Insight Data Engineering Fellows work on during the program are much more complicated and interesting than this coding challenge. This challenge only tests you on the basics.
The original dataset was obtained from the Centers for Medicare & Medicaid Services but has been cleaned and simplified to match the scope of the coding challenge. It provides information on prescription drugs prescribed by individual physicians and other health care providers. The dataset identifies prescribers by their ID, last name, and first name. It also describes the specific prescriptions that were dispensed at their direction, listed by drug name and the cost of the medication.
We designed this coding challenge to assess your coding skills and your understanding of computer science fundamentals. They are both prerequisites of becoming a data engineer. To solve this challenge you might pick a programing language of your choice (preferably Python, Scala, Java, or C/C++ because they are commonly used and will help us better assess you), but you are only allowed to use the default data structures that come with that programming language (you might use I/O libraries). For example, you can code in Python, but you should not use Pandas or any other external libraries.
The objective here is to see if you can implement the solution using basic data structure building blocks and software engineering best practices (by writing clean, modular, and well-tested code).
Your program needs to create the output file, top_cost_drug.txt
, that contains comma (,
) separated fields in each line.
Each line of this file should contain these fields:
- drug_name: the exact drug name as shown in the input dataset
- num_prescriber: the number of unique prescribers who prescribed the drug. For the purposes of this challenge, a prescriber is considered the same person if two lines share the same prescriber first and last names
- total_cost: total cost of the drug across all prescribers
For example
If your input data, itcont.txt
, is
id,prescriber_last_name,prescriber_first_name,drug_name,drug_cost
1000000001,Smith,James,AMBIEN,100
1000000002,Garcia,Maria,AMBIEN,200
1000000003,Johnson,James,CHLORPROMAZINE,1000
1000000004,Rodriguez,Maria,CHLORPROMAZINE,2000
1000000005,Smith,David,BENZTROPINE MESYLATE,1500
then your output file, top_cost_drug.txt
, would contain the following lines
drug_name,num_prescriber,total_cost
CHLORPROMAZINE,2,3000
BENZTROPINE MESYLATE,1,1500
AMBIEN,2,300
These files are provided in the insight_testsuite/tests/test_1/input
and insight_testsuite/tests/test_1/output
folders, respectively.
As a data engineer, it’s important that you write clean, well-documented code that scales for a large amount of data. For this reason, it’s important to ensure that your solution works well for a large number of records, rather than just the above example.
Here you can find a large dataset containing over 24 million records. Note, we will use it to test the full functionality of your code, along with other tests.
It's also important to use software engineering best practices like unit tests, especially since data is not always clean and predictable.
Before submitting your solution you should summarize your approach and run instructions (if any) in your README
.
You may write your solution in any mainstream programming language, such as C, C++, C#, Go, Java, Python, Ruby, or Scala. Once completed, submit a link of your Github or Bitbucket repo with your source code.
In addition to the source code, the top-most directory of your repo must include the input
and output
directories, and a shell script named run.sh
that compiles and runs the program(s) that implement(s) the required features.
If your solution requires additional libraries, environments, or dependencies, you must specify these in your README
documentation. See the figure below for the required structure of the top-most directory in your repo, or simply clone this repo.
The directory structure for your repo should look like this:
├── README.md
├── run.sh
├── src
│ └── pharmacy-counting.py
├── input
│ └── itcont.txt
├── output
| └── top_cost_drug.txt
├── insight_testsuite
└── run_tests.sh
└── tests
└── test_1
| ├── input
| │ └── itcont.txt
| |__ output
| │ └── top_cost_drug.txt
├── your-own-test_1
├── input
│ └── your-own-input-for-itcont.txt
|── output
└── top_cost_drug.txt
Don't fork this repo and don't use this README
instead of your own. The content of src
does not need to be a single file called pharmacy-counting.py
, which is only an example. Instead, you should include your own source files and give them expressive names.
To make sure that your code has the correct directory structure and the format of the output files are correct, we have included a test script called run_tests.sh
in the insight_testsuite
folder.
The tests are stored simply as text files under the insight_testsuite/tests
folder. Each test should have a separate folder with an input
folder for itcont.txt
and an output
folder for top_cost_drug.txt
.
You can run the test with the following command from within the insight_testsuite
folder:
insight_testsuite~$ ./run_tests.sh
On a failed test, the output of run_tests.sh
should look like:
[FAIL]: test_1
[Thu Mar 30 16:28:01 PDT 2017] 0 of 1 tests passed
On success:
[PASS]: test_1
[Thu Mar 30 16:25:57 PDT 2017] 1 of 1 tests passed
One test has been provided as a way to check your formatting and simulate how we will be running tests when you submit your solution. We urge you to write your own additional tests. test_1
is only intended to alert you if the directory structure or the output for this test is incorrect.
Your submission must pass at least the provided test in order to pass the coding challenge.
For a limited time we also are making available a website that will allow you to simulate the environment in which we will test your code. It has been primarily tested on Python code but could be used for Java and C++ repos. Keep in mind that if you need to compile your code (e.g., javac, make), that compilation needs to happen in the run.sh
file of your code repository. For Python programmers, you are able to use Python2 or Python3 but if you use the later, specify python3
in your run.sh
script.
- To submit your entry please use the link you received in your coding challenge invite email
- You will only be able to submit through the link one time
- Do NOT attach a file - we will not admit solutions which are attached files
- Use the submission box to enter the link to your GitHub or Bitbucket repo ONLY
- Link to the specific repo for this project, not your general profile
- Put any comments in the README inside your project repo, not in the submission box
- We are unable to accept coding challenges that are emailed to us
Email us at cc@insightdataengineering.com