r/ProgrammerHumor • • Feb 05 '18

StackOverflow in a nutshell.

Post image
16.2k Upvotes

1.2k comments sorted by

View all comments

Show parent comments

160

u/Kinglink Feb 05 '18

Often times I've seen "That's clearly homework". OK but answer the question. Let the professor worry about if he's a cheater.

0

u/[deleted] Feb 05 '18

[deleted]

72

u/Kinglink Feb 05 '18

At the very least lay out the answer. I fully get "I don't want to help you cheat" but if you have a question like "How do I reverse a string?" You CAN answer the question without making it copy and pastable.

"Go through the string to get the length of the string, or use Strlen() Then use a for loop to cycle between 0 to half the length. For each value, exchange the string pointer + integer with string pointer + length - integer. Now you should have a reversed string" should be a good answer.

I've left a few minor issues and a few optimizations as well as edge cases in there as well, I answer the question but still leave the OP the challenge of coding it and improving it, and testing it.

5

u/PTRWP Feb 06 '18

Pretty off topic here, but why did you do the revered string like that? I'm still learning, but I've reversed strings by creating a new string then using for (i=string.length(); i>0; i--) and within the loop adding the current character to the end of the new string. I made it into a method so I haven't bothered to redo it in a different way since.

→ More replies (3)