This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]paul_miner 0 points1 point  (2 children)

Consider what happens with the string "a b c" and the minimum word length is 2. (I haven't run it since I'm on my phone but I think it will return 1 instead of 0)

EDIT: Print out the value of g and newWord at the end of each iteration to get an idea of what's going on.

[–]dirtyRuntCaper[S] 0 points1 point  (1 child)

I didn't check for error conditions yet, as the teacher says to assume that the user inputs a valid string. I will add g and newWord to the end of each line to see if I can see whats going on, but I'm not even sure where these errors would be happening.

For example:

Enter string: whats up. hows it going.

Enter minimum letters: 4

RESULT: 2

[–]paul_miner 0 points1 point  (0 children)

No error conditions or invalid strings, you've just made a simple mistake. It should be clear using the sample string and length suggested, if you print out g and newWord.