Code Monkey home page Code Monkey logo

phase-1-algorithms-palindrome's Introduction

Palindrome Lab

Learning Goals

  • Practice algorithmic problem solving

Introduction

Now that we've discussed what an algorithm is and defined a problem-solving approach, it's time to apply that to your first algorithm problem! Fork and clone this lab, then read the instructions before running any tests.

Instructions

Write a function isPalindrome that will receive one argument, a string. Your function should return true if the string is a palindrome (that is, if it reads the same forwards and backwards, like "mom" or "racecar"), and return false if it is not a palindrome.

To keep things simple, your function only needs to deal with lowercase strings that are all letters (don't worry about spaces or special characters).

Here are a few examples:

Input: "madam"
Output: true

Input: "robot"
Output: false

Problem Solving Approach

Use the problem solving process described in the previous lesson to come up with an approach to the problem and write your solution:

  1. Rewrite the Problem in Your Own Words
  2. Write Your Own Test Cases
  3. Pseudocode
  4. Code
  5. Make It Clean and Readable
  6. Optimize

Code your solution in the index.js file. There's space in the index.js file to write your pseudocode, but you're welcome to write pseudocode with pen and paper if you find that more beneficial.

You should also write some additional test cases in the index.js file to check your solution. After writing your test cases and coding your solution, you can view the output of your tests by running node index.js in the terminal.

For this exercise, you can use Google to look up syntax and any methods you might need to help solve this problem (note that not all interviewers will allow candidates to look up syntax, but some will).

When you're satisfied with your code, run learn test to run the tests and submit the lab.

Conclusion

In the next two lessons, we'll review some solutions to this problem and talk through how to apply the problem solving process to this exercise. Take your time with this, and give it your best effort before reviewing the solution โ€” it's ok if you don't end up with a working solution on the first try, so long as you make a deliberate effort at developing your problem solving process!

phase-1-algorithms-palindrome's People

Contributors

ihollander avatar munene-kariuki 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.