user2387766
user2387766

Reputation:

Why is my function failing this particular test case?

My function should calculate this value when x and y are on the interval [1, 20]. The irrigation exposure cannot be higher than 10 and when x and y aren't on the correct interval, you return -1.

If my explanation for the function wasn't clear enough here it is on paper: enter image description here

For the case where x and y are both 6, it says that it's 0.000000. But when I do the calculation by hand, I get the output -1. I'm not sure what's wrong with my code and I can't figure out why this particular test case isn't working! Any help is appreciated.

Here's what I get when I ran the test cases: enter image description here

Here are the test cases that I picked: enter image description here

And here's my code for the function: enter image description here

Upvotes: 0

Views: 90

Answers (1)

glglgl
glglgl

Reputation: 91017

There are 2 main points:

  • As was already mentionned, there are no provisions for the case that waterexp > 10.

  • Your expectations are wrong: if x == y, denominator = 1 and waterexp = 12, so you should get 10. There is no reason for it to be -1.

I would have added even a code example if you had provided your code as code, not as a picture.

Upvotes: 1

Related Questions