Git Product home page Git Product logo

assignment-bitmap's Introduction

Test assignment with BFS and Typescript

The idea is to have a 2-dimensional array filled with white and black pixels. And be able to find the closest distance to a white pixel for each black pixel. You can find more details about the assignment here (however, do not look on the solution there. It is elegant but quite slow as it appears to be).

Watch the video first!

I've made a video with explanations of why this solution is chosen, how it works and why is it faster than what can be found over the web.

  • 00:00 — Intro
  • 00:56 — The challenge explained
  • 03:50 — Solutions found around the web
  • 08:25 — Benchmarking my solution vs the one found
  • 11:00 — Validation
  • 13:15 — Input parsing and structure
  • 15:15 — Actual BFS implementation and explanation
  • 18:20 — Testing and linting

Prerequirements

  1. Make sure you have Node, npm and typescript installed globally. Preferred is Node v10.
  2. Download or clone this repo
  3. Run npm install to get all the dependencies

Testing

Right after you've cloned the repo and installed dependencies, it is wise to run tests and see how it works. Run npm run test to test once or npm run autotest to keep Mocha rerunning tests after every change.

The tests are made with Mocha and Chai frameworks.

Building

If you want to build the app without running, run npm run build

Running

To build and run, type npm run start < <YOUR_TEST_DATA>. It will clean up the old build, compile the code and process the file.

Use testData.txt to try the program (like npm run start < testData.txt) and if your test file fails, compare this file to yours to find the difference. Even though, the app has a bit of validation build in and will try to help you finding the error.

Other things to note

This repo is using eslint (with typescript addons) and prettier to automatically lint the code.

assignment-bitmap's People

Contributors

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