GithubHelp home page GithubHelp logo

data-structures-problem's Introduction

data-structures-problem

Start of the Data Structures toy problem

##Background

Your up-and-coming website, Chat-tastic, is set to bring back the chatrooms like no one's ever seen. We're talking 1999, baby.

There is a "server" component to your website that handles all of the users coming and going. Every so often, a new user will join the website and the server will call a function in the global scope called new_user_joined. Periodically, the server will also call a function in the global scope called assign_to_chatroom which will give you the ability to proportion users where they need to go.

Your job is to assign the users to chatrooms based on their order of appearance (first come first served). You should also try to keep the chatrooms equally full.

##Objectives

###1. Capture all incoming users in an appropriate data structure in the function new_user_joined

Because you don't know when new users will be coming, you need to capture all of them so that when the assign_to_chatroom function is called, you're ready to assign them to an appropriate room.

Hints

  • Open up the page in your brower and look at the console. The logs coming through should give you an indication of when different methods are being called.
  • The users_joined array is already provided for you as a start
  • Which data structure uses the "first come first served" policy? What are that data structure's methods?
  • Use the new_user_joined function when you're adding users to your data structure

###2. Assign users in order of appearance to a chatroom Every five seconds the server will call the function assign_to_chatroom and you'll need to place each user in your data structure to a chatroom. A button element (see the commented code in assign_to_chatroom) needs to be added for every new user in each room.

Hints

  • In the assign_to_chatroom function, you'll go through your users_joined data structure, pulling out users in order of appearance and inserting them into the DOM via jQuery
  • To keep both containers equally full, you could:
    • Create a variable that tells you which container you're going to use next, then when you've used it, point the variable to the other container
    • Create a boolean variable that when true, indicates using one container and when false, indicates you should use the other. Change the boolean every time a student is assigned.

###3. (Black Diamond) Make sure there are no repeats of users in a room

Hints

  • See the chatrooms variable? What data struture does that look like? How could you use it to make sure there are no repeated users?

data-structures-problem's People

Contributors

cahlan avatar

Watchers

James Cloos avatar Jeffery Davis 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.