You are viewing a single comment's thread. Return to all comments →
In case it is useful for someone, in the context of this challenge, a valid function is that which for a given input, ALWAYS gives the same output.
Given a function f() that functions as:
It is considered VALID, as outputs are always in a 1:1 relation with inputs, even although we don't know the exact way the relationship (function) works (i.e. we got no idea how f(4) gives 1000).
A function g() which functions as follows:
The above function g, is NOT VALID, since, for input 2, we get two different results, first 333, then later we get 777.
NOTE : It is worth noting that multiple inputs may give the same output:
Would still be a valid function.
Nice explaination. I was confused by this notion too.
This practice's test cases do not concern about
Thank you, your explanation makes a whole lot more sense than the one which is provided.
Good explanation. Another way to think about it that helps me (though if it doesn't help you, probably best just to forget about it) is to consider the result if I graphed the function. So if the x axis is x, and the y axis is f(x), then for a valid function, there should be no place along the x axis where I could draw a vertical line directly down or up and have that line intersect the function's curve/line in more than one place.
Using the examples given above, if you graphed the valid function outputs, you would see that there is only one output for each x input (i.e. only one spot on the graph for each x), and thus I cannot draw a vertical line intercepting the function in more than one place. That is NOT the case however with the invalid input, as I could draw a line and intercept the function's output for 2 at two places.
I hope this helps to clarify things for someone :)