Giter Site home page Giter Site logo

paambaati / bumplan Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 276 KB

A simple program that finds the seating arrangement for passengers for a given custom airplane seat layout.

License: Do What The F*ck You Want To Public License

TypeScript 100.00%
nodejs algorithm data-structures interview-questions coding-challenge

bumplan's Introduction

bumplan

WTFPL License

A simple program that finds the seating arrangement for passengers for a given custom airplane seat layout.

Screenshot

๐Ÿ“ฃ Note that this project was purpose-built for a coding challenge (see problem statement).

๐Ÿ› ๏ธ Setup

Before you run this app, make sure you have Node.js installed. yarn is recommended, but can be used interchangeably with npm.

git clone https://github.com/paambaati/bumplan
cd bumplan
yarn install && yarn build

๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป Usage

yarn start "<seat_layout>" "<passengers_count>"

๐Ÿงช Tests & Coverage

yarn run coverage

๐Ÿงฉ Design

  1. The program first builds a "mapping" for the given layout (see buildSeatMapping()). Essentially, the input 2D array is flattened and a lookup table is built, along with the seat types.

    For example, for the layout โ€”

    [[1, 2], [3, 2]]

    The mapping built is โ€”

    {
        '0_0_0': 'W',
        '1_0_0': 'A',
        '1_1_0': 'M',
        '1_2_0': 'W',
        '0_0_1': 'W',
        '1_0_1': 'A',
        '1_1_1': 'M',
        '1_2_1': 'W'
    }
  2. The mapping is then used to filter by seat types first and then iterated over to assign passenger number (see assignSeats()). As a nice bonus, the method will also optionally take a priority list, so it will be easier to alter the seating rules in the future.

  3. The seat assignment is then printed on the screen (see printSeatAssignments()). It uses the super-lightweight colorette to print in colors to quickly distinguish the seat types.

bumplan's People

Contributors

paambaati avatar

Stargazers

 avatar

Watchers

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