paambaati / bumplan

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

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


Languages

Language:TypeScript 100.0%