Code Monkey home page Code Monkey logo

check_it's Introduction

check_it

Setup

In this activity, you will model a Stack as a stack of index cards.

Start by creating 3 index cards with the following characters:

  1. "{"
  2. "["
  3. "("

As the examples get more complex, you will need to create more index cards when you have multiple of the same character.

Activity

Run the check_it.rb file. For each of the examples provided at the end of the file:

  1. Every time the Stack#push method is called, put that character on top of the Stack.
  2. Every time the Stack#pop method is called, remove the top index card from the Stack.

After you have looked at all examples, answer the following questions:

Check for Understanding

  • What is the check_it algorithm checking?
  • What other applications could this algorithm have?
  • What kinds of problems are Stacks good at?

Bonus

Implement the following methods for the Stack class (be sure to use TDD):

  • search(element) - search for element and return its index, or nil if not found
  • peek - return, but don't remove, the top element
  • clear - clear the Stack
  • empty? - return a boolean indicating if there are any elements in the stack

check_it's People

Contributors

brianzanti avatar

Watchers

James Cloos 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.