Giter VIP home page Giter VIP logo

fire-station-problem's Introduction

Fire Station Problem

The Problem:

Imagine you have a fire station with four levels of employees: a junior, senior, manager and a director. All callers and employees Ids and names are registered and tracked.

Specs:

  • An incoming telephone call will be throttled to the system with a priority level (Low and High.)
  • For low-priority calls: any call must be first allocated to a junior who is free. If not, then the call must be escalated to a senior. If a senior is not free or not able to handle it, then the call should be escalated to one of the managers.
  • For high-priority calls: these can only be answered by managers and directors. Any call must be first allocated to a manager who is free. If not, then the call should be escalated to one of the free directors.
  • Sometimes, and via a random value for now, low-level calls can be changed to high-level calls after being allocated and should then be pushed again to the system to be picked up as a high-priority call.
  • All employees start with ‘free’ status. They change their status upon allocation and de-allocation of calls.
  • the employee status changes to ‘free’ whenever:
    • a call is finished,
    • OR a call is escalated from the employee to another employee

The System:

  • Design the classes and data structures for this problem. Implement a call to DispatchCall() which assigns a call to the first available employee.
  • No need to develop an actual server or any use of threading. The system should work as a simulation given a particular input and some random variables.
  • You only need a script to generate and simulate the calls via intervals (random timer). The system should be able then to consume these calls and allocate the corresponding employees. In case of all employees are busy, the system should put any call on hold till someone is available again.

Running

  • Virtual Environment:
    • Built with Python 3.10. To replicate the venv run:
    • python3 -m venv venv
    • cd venv/source/bin
    • source activate
    • cd ../..
    • pip install -r requirements.txt
  • See Useful Commands to run tests
  • Simulation:
    • python run_simulation.py

Useful Commands

  • Testing:

    • pytest --cov
    • pytest --cov --cov-report=html
    • coverage html
    • mypy --no-namespace-packages --config-file mypy.ini src
  • Linting:

    • black -l 88 src
  • Requirements:

    • pip install pip-tools
    • pip-compile requirements.in -o requirements.txt
    • pip install -r requirements.txt

Implementation Limitations

  • Inefficient Call Assignemt O(n)
    • Currently doesn't account for assigned/not assigned, goes through all employees to find a fit regardless of their status
    • Solutions: (i) database filtering; (ii) 2 lists (free, available) - O(1)
  • Inefficient active calls review - iterative poping O(n)
    • However, this functionality is just for mimicking, in reality, should be managed when the end of a call is initiated by an agent
  • Missing:
    • Docker
    • CI/CD

fire-station-problem's People

Contributors

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