Originally posted by avelin chen:
Yeah, that was my problem, but what I don't get is how I check to see if the punctuation marks were removed. Should I use an if else statement?
Originally posted by avelin chen:
Could I possibly divide the String in half, and check from both ends to see if I can insert a letter in there?
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Originally posted by Garrett Rowe:
Consider:
Add the first letter.
Is this a palindrone?
Originally posted by avelin chen:
So, it will like comparing each substring until you get one that is a paindrome right?
Originally posted by avelin chen:
I think I get the process of doing this, but what I don't get really is after I have found where I nedd to add the letter(s), how do I add it on? I know this sounds dumb, but do I use the concat method? Also, once I have found the palindrome, how do I tell it to stop at that point?
function leastPal takes String s and returns String loop create a String temp if temp is a palindrom return temp end loopend function
I get what my process should be, but I just don't know how to write it out.
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
Originally posted by Garrett Rowe:
One additional thing to think about when solving this problem would be consider the string "acecar". By just adding characters to the end the least palindrone would be "acecaraceca", but you can obviously make a shorter palindrone by adding an 'r' to the beginning of the word. So maybe your program should add both ways and compare the two results to see which one is shorter. Bonus points if they are the same size and you return both in a String[].
Originally posted by avelin chen:
So, I know that if it already a palindrome, it just returns the original String. But, if it is not, then it goes through the least palindrome thing. I know that I want to take the original String and tack it on backwards, but it has to use the least amount of letters. So, I could probably let it go through the isPal thing with the last letter first, and then move forwards, right?
Don't get me started about those stupid light bulbs. |