Code Monkey home page Code Monkey logo

tuxt-dev's Introduction

Tuxt coding challnege

This repo contains the solution for both tasks asked by Tuxt team

This application supports the Getting Started on Heroku with Node.js article - check it out.

Running Locally

$ git clone [email protected]:emanuelmetal/tuxt-dev.git # or clone your own fork
$ cd tux-dev
$ yarn install

Task 1

For this task to run locally a PostrgreSql instance is required, wherever it is and the connection string sould be set on DATABASE_URL

To run the project run:

$ yarn start

The app should now be running on localhost:5000.

main files are index.js & api/messages.js

Task 2

This task will expect 2 arguments, the file with prices and the gift card balance. To run this project type:

$ yarn run task2 -- giftCardBalance=87 fileName=task2/data.json

There is a sample file at task2/data.json

The src file is at task2/task2.js

This solution supports only getting 2 gifts to settle the balance at will do it in O(n) time. Specific solutions are better than generic ones to handle N gifts. So to get 3 or more gifts the complexity will increase. So to do that we will need a more complex algorithm and the usage of Workers. The loading of the file must be async and the computation of the N gifts shoukld be sent to a tread Worker so the server cancontinue with something else. A promise is not the solution since when it starts a heavy computation will block the event loop until it finish the task.

tuxt-dev's People

Contributors

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