I had a programming test where was asked to do a particular problem. However, there was some kind of mistake in a problem as I was able to see that there can't be particular type of inputs for the function. Is the correct way to answer the question something like "By working over the field Z/9Z we see that there is no inputs of the given form" or "Let us modify the problem a bit and remove that condition. Then the following algorithm will do the job."?
Why not do both? Explain the issue that keeps you from completing the exercise as it's written, and then provide an alternate approach that gives the same results. This will show that you understand the problem domain, and that you're experienced and flexible enough to determine the root cause and provide another solution.