DEV Community

KevinSarav
KevinSarav

Posted on

Data Structures Project 2: Palindrome Detector

This is an unexpected post, but I thought it'd be valuable if I jot down my thoughts on my project for Data Structures. I will work on my Calculator project in a future post.

This project basically looks through a .txt file line by line to check for any palindromes. It seems pretty straightforward. I will need one for loop that goes line by line, then another that goes word by word, and then another that goes character by character. In the .txt file, there are spaces, commas and apostrophes in the way, but the code still checks the palindrome for that line regardless. I will need to think of a way to ignore anything that is not a letter. That means I probably need to check the char (ASCII) value for every character. If this char value is not within the range of the alphabet, then that character will not be added to a new string that I’m making that will consist of only letters.

Once this new string is made, then I will make a loop to invert the letters. I can probably make due with a loop that goes through half of the string and switches the letters around. If a make a loop that goes through the whole string, then I would be making the string backwards and then forwards, if that makes sense.

At the end, I will have another for loop that will go through both strings character by character to make sure all match. If they don’t, then it’s not a palindrome that will be outputted.


I will work on this project tonight. Overall, it seems straightforward, but I’m sure to come up with challenges. In this post, I briefly described how I will do a Palindrome Detector project. Basically, I need to implement a way to check character by character, a way to ignore anything that’s not a letter, and a way to invert a line. In my next post, I will discuss unexpected challenges I faced with this project and possibly any continuing work in my Calculator project.

Top comments (0)