We have some customer records in a text file (customers.txt) -- one customer per line, JSON lines formatted. We want to invite any customer within 100km of our Dublin office for some food and drinks on us. Write a program that will read the full list of customers and output the names and user ids of matching customers (within 100km), sorted by User ID (ascending).
-
You must use the first formula from this Wikipedia article to calculate distance. Don't forget, you'll need to convert degrees to radians.
-
The GPS coordinates for our Dublin office are 53.339428, -6.257664.
-
You can find the Customer list here.
We're looking for you to produce working code, with enough room to demonstrate how to structure components in a small program. Good submissions are well composed. Calculating distances and reading from a file are separate concerns. Classes or functions have clearly defined responsibilities. Poor submissions will be in the form of one big function. It’s impossible to test anything smaller than the entire operation of the program, including reading from the input file.
Node >= v10 Jest >= v24
- TARGET_LOCATION_LATITUDE - target latitude, Dublin Office by default
- TARGET_LOCATION_LONGITUDE - target longitude, Dublin Office by default
- PATH_TO_CUSTOMERS_FILE" - path to file with customers records
- Clone this repository
- Go to the repository folder
- Install dependacies by running
npm install
In the project directory, you can run:
Run the app, output results to console
Launches the test runner - Jest.
Launches the test runner with information about code coverage
In output.txt
you can find the result of the app running with given customers list.
You can run this app in docker container.
Run this command to create image.
Run the app inside docker container