What am I doing here?!

Good Morning Guys,

I’ve recently completed a beginners Java course and I found this site to help me practice. I’m doing “The Descent” puzzle, and man, my head is spinning. I’ve searched the forum for an answer to my question and I couldn’t find it.

After I succeed in completing one test case and move on to another, the previous successful one will have an explaination mark and says “Check Again”. Why. When I try to submit, I never receive a score. Why. How do I play all test cases when I’m changing my output for the different test cases? What are validators? What does hard-coded mean? Can someone explain this to me as if you are talking to a 5 year old.

Thank you

Programming is not like solving problems on a piece of paper. Your code should handle various cases, not just the current test. When your program is running, you will get different input variables (which might change every time you start your program). Your code should act upon these variables using ifs, loops, … etc. where you use the variable values to figure out what the program should output.

  • Validator is inputs not seen as test cases.
  • Hard-coded: Some code created to solve a specific test case (like you would solve a crossword puzzle on paper). Not the general problem of various inputs.
3 Likes

To teach a 5-year old kid how to cross the road, “Go on the street. If you see a car coming, stop and wait for it to pass. If you see the road is clear, walk across it.”

The output depends on the inputs. If all assumptions are correct, it should work for all cases.

If you teach the kid, “Walk 20 steps. Stop. Wait for 30 seconds. Then walk again for 30 steps.”
This is hardcoding. It may work to successfully cross the road in one case. It will not work for most other cases.

Which style your program was written to save the Enterprise?

9 Likes

Thank you for the explaination. I understand this. :+1:t5:

1 Like

Thank you for this! I get what you’ re saying. When I considered my output, I didn’t think to break it down this way. I just did one simple output of “System.out.println()” for each target. Now I know, to think about all varibles when coding.

2 Likes