The usual expectation when asking for debugging help on Stack Overflow is a Minimal Reproducible Example, including any program input needed to reproduce the issue, and the exact text of compilation or runtime error messages.
However, sometimes new users come here looking for help with code that they are writing for a coding challenge (leetcode, hackerrank, etc). In such cases, they might have trouble creating a minimal reproducible example:
Their code might not constitute a complete program, because the challenge might be just to write a single function. (The challenge site might execute it within some testing harness that is not provided to the user.) So they may not have a main function, complete definitions of data structures, etc.
They might not have access to the exact input data that causes the failure, because sometimes these sites use secret test data.
They might have trouble finding out how the program is failing, because the site might use a compiler or interpreter with unhelpful error messages, or just indicate success or failure without further info.
They might not have development tools for their language installed locally; they could be relying on just editing and submitting code directly to the site.
They might not even be able to use printf debugging, because they might not get access to their program's output (to prevent them from recovering the secret test data).
Such questions sometimes get into a pattern of: New user posts their attempted submission; post gets closed because it isn't an MRE; new user gets frustrated because they don't have the things that an MRE asks for, and don't know how to produce them; experienced users try to explain in comments, but lose patience because they've explained the same things hundreds of times before on similar comments; things get testy; new user leaves in a huff and thinks SO is terrible.
What are some more helpful pieces of advice for new users in this situation, that may help guide them toward writing a question that can be well received and answered? Then we can point them to this meta post, rather than trying to rehash the same points in comments every time.
If possible, please try to write answers that will be friendly and accessible to newcomers. New users in this situation may be unfamiliar with the SO model and community norms; may be inexperienced with the programming language they're using; and may be unfamiliar with basic concepts and techniques of software development and debugging.
(Let's set aside the question of whether it is ethical to request or provide assistance with such problems and assume that we are treating such questions like any other question.)
Their code might not constitute a complete program, because the challenge might be just to write a single function
- I don't see how that's a problem. Depending on the language, a single function is just fine for a programming problem.main()
function), and the code written by the asker consists only of anaddTwoNumbers()
function. Sure, it's a valid problem specification to say "write anaddTwoNumbers()
function", but it's not reproducible: if I want to test their code to try to find the problem, I'll have to write my ownmain
function to call theirs, as well as constructing appropriate input objects.main
is a dead give-away that no effective testing and debugging took place and, regardless of whether or not the question is answerable from the given snippet, the voting will reflect this. Never discount the social importance of showing your work.main
function, headers, etc. They responded that they didn't have any of those because leetcode didn't require it, and didn't seem to understand that this wasn't a satisfactory answer. I didn't have the patience to explain to them why not, and what they needed to do, but if there'd been a post like this to point them to, it could have done them some good.