Skip to content

Instantly share code, notes, and snippets.

@vbrazo
Created December 3, 2018 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vbrazo/ef26e442d2573c481436461910193b90 to your computer and use it in GitHub Desktop.
Save vbrazo/ef26e442d2573c481436461910193b90 to your computer and use it in GitHub Desktop.
## Hints & what we're looking for
* We're more **interested in the process** than in the final result. You
probably won't finish the whole task in the given time.
* You are free to **use anything you use in your daily work**, including
websites like Google or StackOverflow.
* You can use any language or tool you want, but we recommend that you use the
language you feel most comfortable with and keep it super simple.
**You don't need a database or framework**, a simple command line script that
computes the values and prints them to the console is just fine for us. You
can even hard code those invoices and the credit line in the script to skip
the JSON parsing.
* First make your code work, but afterwards take the time to make it nice. We
would like to see maintainable & readable code.
**Simple scripts should have nice code**, too. Please use features like
classes, methods or functions!
We finance invoices of its customers by paying out the invoice amount
before it is collected. These invoices will be paid back by the customer of our
customer, who we call a debtor.
![](https://gist.github.com/iGEL/e62b5bf58de4a4db18dec21d290362a6/raw/37b7cbcc6b667a50a86ae6e402a40f2bdaae8ccf/how-it-works.png)
For our tasks, we'll be using the following data:
* [invoices.json](https://gist.github.com/iGEL/e62b5bf58de4a4db18dec21d290362a6/raw/37b7cbcc6b667a50a86ae6e402a40f2bdaae8ccf/invoices.json)
* [credit_line.json](https://gist.github.com/iGEL/e62b5bf58de4a4db18dec21d290362a6/raw/37b7cbcc6b667a50a86ae6e402a40f2bdaae8ccf/credit_line.json)
The credit line is the maximum amount the customer can get.
## The Task
Please write a script that given the invoices and the credit limit above computes the
following values.
* Financed amount, which would be:
```json
40000
```
* Financed amount of each invoice (A hash/map of invoice number to financed
amount). A possible result is:
```json
{
"inv-kola1": 16000,
"inv-burger1": 15000,
"inv-kola2": 9000,
"inv-burrito1": 0,
"inv-burger2": 0
}
```
* Remaining customer credit:
```json
0
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment