Code Monkey home page Code Monkey logo

pharmacy-counting's Introduction

Run instruction

The solution was programmed with Python 3.6.2. In the 'run.sh' I still use python and it worked.

The running of the solution requires no additional library, environment, or dependency. Only the Python Standard Library is used.

The code was tested on a computer with Windows Subsystem for Linux (Ubuntu 16.04.2 LTS). The two bash files 'run.sh' and 'run tests.sh' worked well on the test1 coming with the challenge and also my own test2 as shown in the folder. I also tested the large dataset containing over 24 million records over here, it worked but I didn't have a way to validate the result for such a large file.

Approach

For this challenge, I employed a 'cost' dictionary to record the total cost of a single drug, and another 'prescriber' dictionary to record all the unique prescribers for the drug. The dict key for the all two dictionaries are the name of the drug, and I use the combination of the last name and first name for identification of each unique prescriber. The steps of the solution are as below:

  1. Streaming each line from input file.

  2. Identify and name all the useful fields from each line, and validate those input items in the right format, specifically, the 'id' should be in int format and cost should be in float format. This part was done by the codes in helper.py.

  3. Go through the input file and record all the drugs and their total costs as well as the unique prescribers. The prescribers were recorded in a set in the dictionary data to make sure they are unique.

  4. Sort the drugs in descending order based on the total drug cost and if there is a tie, drug name. Write the sorted drug information to the output file.

pharmacy-counting's People

Contributors

renlei1982 avatar emhoa avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.