Skip to content

This project contains implementations of a seating arrangement algorithm using four different approaches: us module, using standalone functions, and using Python's zip function along with the built-in sorted function.

License

Notifications You must be signed in to change notification settings

thomasthaddeus/MusicalChairs

Musical Chairs

Deploy Jekyll GitHub top language GitHub repo size

Table of Contents

Introduction

This project is a simple web application that demonstrates the use of four different approaches to solving the musical chairs problem.

The Musical Chairs Problem

Suppose that you are hosting a dinner party and have invited some number of guests. When the guests arrive, you realize that you don't have enough chairs for everyone. You decide to solve this problem by asking some of the guests to stand while the others sit. Your guests are all very close friends and have no preference for where they sit at the table, but you would like to maximize the number of guests sitting at the table.

The Algorithm

The algorithm is implemented in four different ways. The basic idea is to sort the guests by their total number of friends. Then, starting with the guest with the most friends, assign them a seat at the table and remove them and all of their friends from the list of guests. Repeat this process until there are no guests remaining. The different implementations of the algorithm differ in how the guests are sorted.

The Web Application

The web application is built using Jekyll. The source code for the web application is located in the src directory. The web application is deployed to GitHub Pages and can be accessed via the following link Musical Chairs

About the Project

This project contains implementations of a seating arrangement algorithm using four different approaches:

  1. using a class
  2. using Python's heapq module
  3. using standalone functions
  4. using Python's zip function
    • with the built-in sorted function.

Built With

Directory Structure

The project has the following directory structure:

.
├── .gitignore
├── LICENSE
├── README.md
└── src
    ├── app
    │   ├── main.py
    │   ├── pylint.rc
    │   ├── logs
    │   │   ├── class.log
    │   │   ├── hq.log
    │   │   ├── standalone.log
    │   │   └── zip.log
    │   ├── _main
    │   │   ├── _decorators_main.py
    │   │   └── _functions_main.py
    │   ├── modules
    │   │   ├── __init__.py
    │   │   ├── with_classes.py
    │   │   ├── with_heapq.py
    │   │   ├── with_standalone.py
    │   │   └── with_zip_sorted.py
    │   └── tests
    │       ├── __init__.py
    │       ├── test_main.py
    │       └── test_modules.py
    ├── css
    │   └── styles.css
    └── js
        ├── accordion.js
        ├── dropdown_enhancements.js
        ├── fetch.js
        ├── myModal.js
        └── smooth_scrolling.js

Files Overview

  • README.md: This file.
  • main.py: This script executes each implementation and prints their outputs and execution times.
  • with_classes.py: Implementation of the algorithm using a class.
  • with_heapq.py: Implementation of the algorithm using Python's heapq module.
  • with_standalone.py: Implementation of the algorithm using standalone functions.
  • with_zip_sorted.py: Implementation of the algorithm using Python's zip function along with the built-in sorted function.
  • test_main.py, test_modules.py: These are pytest files for testing each of the four implementations.

Running the Tests

To run the tests, you will need to install pytest

pip install pytest

Then you can run pytest command from your terminal at the root directory of the project.

About

This project contains implementations of a seating arrangement algorithm using four different approaches: us module, using standalone functions, and using Python's zip function along with the built-in sorted function.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published