Git Product home page Git Product logo

word_ladder's Introduction

Word Ladders with Stacks and Queues

You will implement a solution to Lewis Carroll's word ladder game.

Learning Objectives:

  1. implement a complex algorithm involving both queues and stacks
  2. understand python memory management
  3. practice translating pseudocode into python

Relation to technical interviews:

Leetcode is a common method used for technical interviews. The world ladder problem is an example of a problem that leetcode puts in their hardest-to-solve category (see the problem description on leetcode.com). What makes these problems "hard" is figuring out the right pseudocode. Translating from pseudocode into working code is considered "easy".

In this assignment, we will practice the translation of pseudocode into working python code. If you want to learn more about how to create the pseudocode in the first place, then you should take CSCI148: Graph Algorithms with Prof Sarah Cannon.

Background

A word ladder is a list of words where each word differs by only a single letter from the previous word. For example, we can convert a stone into money using the following ladder:

stone
shone
shote
shots
soots
moots
motts
motes
motey
money

In this assignment, you will implement a function word_ladder that generates these word ladders. There are many possible algorithms to generate word ladders, but a simple one uses a combination of stacks and queues as shown in the following pseudocode.

Create a stack
Push the start word onto the stack
Create a queue
Enqueue the stack onto the queue

While the queue is not empty
    Dequeue a stack from the queue
    For each word in the dictionary
        If the word is adjacent to the top of the stack
            If this word is the end word
                You are done!
                The front stack plus this word is your word ladder.
            Make a copy of the stack
            Push the found word onto the copy
            Enqueue the copy
            Delete word from the dictionary

HINTs:

  1. This pseudocode is intentionally vague, and I encourage you to ask clarifying questions. The ability to ask good questions is one of the keys skills being tested in technical interviews.

  2. One of the main differences between pseudocode and real code is that pseudocode doesn't have to deal with memory management, but real code does. The vast majority of bugs that students get with this assignment is due to memory management issues.

  3. The test cases take a long time to run, and you will not be efficient if you are re-running them all the time. Instead, use the --last-failed flag in pytest to skip the tests that you have previously passed and only run the failing tests.

Tasks

Complete the following tasks:

  1. Fork the this repo and enable github actions
  2. Update the README.md file so that the travis button points to your repo
  3. Implement the word_ladder, verify_word_ladder, and _adjacent functions so that all test cases in tests/test_main.py pass

Your grade will be the percentage of test cases that successfully pass in travis.

Submission

Submit the link to your forked repository on sakai.

Collaboration Policy

You are not allowed to look at another student's github repo.

All other forms of collaboration with other students are encouraged. You may use any other online resources you like to complete this assignment.

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.