You are viewing a single comment's thread. Return to all comments →
Can anyone clarify what they mean by "a valid function"? My understanding is that each domain value must map to only 1 value in the range. But the relationship can be arbitrary.
Does the question imply one-to-one functions (where the inverse is also a function)?
Are they looking for relationships that can be represented by algebraic expressions? Why not trig functions?
As per the given constraints "x and y both are integers" it may not constitue to trig functions
I was confused by this too. Have a go at submitting any old solution, then look at the cases for test 2 where the result should be 'NO' and it should all become clear.
I too examined the test data, but got stumped by #2 in test 2 which flags as a valid function. At the end it changes from being a linear relationship into something quite different. I guess I am missing the intent of the question. e.g.
Hi All. After sleeping on it & debugging my I/O code, I prepended each result to a List, but forgot to call .reverse before printing! So my output was in the wrong order.
For anyone looking for "what is a valid function", this is a good reference:
Thanks. Armed with that link I was able to solve the problem. I admit I probably should have googled it first.
You already said it all: the only constraint to have a function is that the x-values must be distinct for distinct y-values. There is no other restriction. (It happens that here all values are integers, but that's not part of the definition of a function.) But it could a priori happen that a given pair (x,y) is listed twice.