Here is the description:
CHALLENGE DESCRIPTION:Trim did not mean what I thought it meant. To me, trimming is removing white spaces.
Trimming to 40 characters to me would mean... line.substring(0,40); //(JAVA)
I was really confused at why non of the read-more example output stopped in the middle of a word.
Because of a bad example, I couldn't figure out if that was co-incidental or by design.
Example: With the input:
123456789 123456789 123456789 123 Supercalifragilisticexpialidocious
I was pretty sure due to the instructions, the proper output would be something like this:
123456789 123456789 123456789 123 Superc... Read More
But the correct answer is more like:
123456789 123456789 123456789 123 //Notice the absence of the sliced in half "Superc"
So... What they are actually asking you to do is:
If the line is > 55 characters:
1. Tokenize the line using " " as a delimiter.
2. Build the string back up, stopping before you go over 40 characters.
3. If you get a zero-length string this way, just do line.substring.split(0,40);
I hope this helps someone.
Judging by everything I read on the internet.
I seem to be the only one who couldn't make sense of the instructions.
I really hate problems where the majority of why I can't solve it is because I don't know
what it is asking.
Today definitely re-affirms my grandfather's saying:
"A problem well stated is a problem half solved."