Giter Club home page Giter Club logo

thomasthaddeus / musicalchairs Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.18 MB

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.

Home Page: http://thomasthaddeus.com/MusicalChairs/

License: GNU Lesser General Public License v3.0

Python 75.66% CSS 9.62% HTML 8.47% JavaScript 6.24%
optimization-algorithms python data-structures interview-questions lgplv3 python3

musicalchairs's Introduction

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.

musicalchairs's People

Contributors

thomasthaddeus avatar

Stargazers

 avatar

Watchers

 avatar

musicalchairs's Issues

Logger

The main function should be broken up so that the logger does all its magic before main is run

[Bug]: Gits being annoying

Product Version

1.0

Bug Description

Gits not letting me merge into a unified history

Steps to Reproduce

dont

Expected Behavior

That the branch would merge and not start doing crazy solutions. I'm about to cherry pick this

Actual Behavior

I was trying to merge a commit and it popped it and then all kinds of history issues started

Additional Information

Don't move your repos

Confirmation

  • I have described the issue in as much detail as possible.
  • I have included any additional information that might help diagnose the problem.

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.