Coder Social home page Coder Social logo

fetch-point-redeem's Introduction

Fetch-point-redeem

Fetch Coding Exercise - Software Engineering Internship What do I need to submit? Please write a program that reads from a CSV file called transactions.csv in the current working directory, processes an argument, and returns a response based on the conditions outlined in the next section. You can use any language.
We must be able to compile and run your code; provide any documentation necessary to accomplish this as part of the code you submit. Please assume the reviewer has not executed a code in your language before when developing your documentation. What does it need to do? Background Our users have points in their accounts. Users only see a single balance in their accounts. But for reporting purposes, we actually track their points per payer. In our system, each transaction record contains: payer (string), points (integer), timestamp (date). For earning points, it is easy to assign a payer. We know which actions earned the points. And thus, which partner should be paying for the points. When a user spends points, they don't know or care which payer the points come from. But, our accounting team does care how the points are spent. There are two rules for determining what points to "spend" first: We want the oldest points to be spent first (oldest based on transaction timestamp, not the order they’re received) We want no payer's points to go negative. We expect your code to Read the transactions from a CSV file. Spend points based on the argument using the rules above. Return all payer point balances. Example

  1. When you run your program, you will pass in an argument which is the amount of points to spend. For example, using a Python program to spend 5000 points would look like this:

python3 mycode.py 5000 2. Your code will ingest a CSV file with an example sequence: "payer","points","timestamp" "DANNON",1000,"2020-11-02T14:00:00Z" "UNILEVER",200,"2020-10-31T11:00:00Z" "DANNON",-200,"2020-10-31T15:00:00Z" "MILLER COORS",10000,"2020-11-01T14:00:00Z" "DANNON",300,"2020-10-31T10:00:00Z"

  1. After the points are spent, the output should return the following results: { "DANNON": 1000, "UNILEVER": 0, "MILLER COORS": 5300 } In this repo, it included mycode.py and data file transactions.cvs.

How to run the code in your terminal

Using the following command line to run this code

Get the repo

git clone https://github.com/woshicqy/Fetch-point-redeem.git

Move to the folder

cd Fetch-point-redeem

To run the code,install the packages first.

pip install -r requirements.txt

Ready to run the code.

python -u mycode.py --remaining 5000

After running the code, you will get the output in your terminal, and it will generate on file named output.csvwith the printed output in your local machine.

accounts:defaultdict(None, {'DANNON': 1000, 'UNILEVER': 0, 'MILLER COORS': 5300})
points_spent info:[['DANNON', -100, 'now'], ['UNILEVER', -200, 'now'], ['MILLER COORS', -4700, 'now']]

fetch-point-redeem's People

Contributors

woshicqy avatar

Watchers

 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.