GithubHelp home page GithubHelp logo

st-reimbursement-exercise's Introduction

Simple Thread Technical Exercise

This repository is a container for the technical exercise given to me for my job application to Simple Thread. It is written in Typescript and tested with Jest.

Goal

Given a set of projects, calculate the reimbursement amount for the set.

Rules

  • First and last days of projects/sets are travel days
  • Middle days are full days
  • Gap days should not be billed
  • Days on the ends of gaps between projects are travel days
  • Projects that touch or overlap days are full days
  • Days are only ever counted once
  • Projects are in either high or low cost cities
  • Days should be counted to maximize reimbursement total

Rates

full travel
high cost $85 / day $55 / day
low cost $75 / day $45 / day

Running the code

To run the project and calculate reimbursement for the 4 given sets in the /data folder, first install the necessary dependencies.

npm install

Note: If you get an error that dependencies couldn't be installed correctly, make sure the version of Node you're running is v14.16.0 or later. You can do this easily if you have nvm installed by running nvm i.

Run using Jest

If you'd like to just run the tests in the test-file using Jest, you can run:

npm run test

or

jest

Run using build script

If you'd like to just see a printout of the results from testing the given data-sets, I created a build script that does just that. You can run it with the following command:

npm run calc

Related Info

Type definitions

ProjectData: {
    cityCost: bool (true is high cost | false is low cost);
    startDate: string (in month/day/year format);
    endDate: string (in month/day/year format);
}

Testing Sets

Set 1

Should calculate to 165

[
    {
        cityCost: false,
        startDate: 9/1/15,
        endDate: 9/3/15
    }
]

Set 2

Should calculate to 620

[
    {
        cityCost: false,
        startDate: 9/1/15,
        endDate: 9/1/15
    },
    {
        cityCost: true,
        startDate: 9/2/15,
        endDate: 9/6/15
    },
    {
        cityCost: false,
        startDate: 9/6/15,
        endDate: 9/8/15
    }
]

Set 3

Should calculate to 475

[
    {
        cityCost: false,
        startDate: 9/1/15,
        endDate: 9/3/15
    },
    {
        cityCost: true,
        startDate: 9/5/15,
        endDate: 9/7/15
    },
    {
        cityCost: true,
        startDate: 9/8/15,
        endDate: 9/8/15
    }
]

Set 4

Should calculate to 215

[
    {
        cityCost: false,
        startDate: 9/1/15,
        endDate: 9/1/15
    },
    {
        cityCost: false,
        startDate: 9/1/15,
        endDate: 9/1/15
    },
    {
        cityCost: true,
        startDate: 9/2/15,
        endDate: 9/2/15
    },
    {
        cityCost: true,
        startDate: 9/2/15,
        endDate: 9/3/15
    }
]

st-reimbursement-exercise's People

Contributors

drewlyton 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.