31

I was sent a technical test by a potential employer that was impossible to complete. The test contained invalid code under a "Do not change this code" comment. In addition, the web page had glaring issues and refused my answers for one of the other questions.

I have scoured the documentation of the C language and I am certain, beyond any doubt in my mind or that of any peers I have consulted, that the test sent to me was invalid and impossible.

I sent these concerns and after being ignored, I followed up and was met with "Other candidates passed the test successfully; you were the only one that had issues". They have excluded me from moving forward as a result.

I don't know what to do here. It is driving me crazy, because I am so fundamentally certain that it is impossible, but "somehow" other candidates did the test. My request to see a solution that worked and followed the outline of the test was not acknowledged. I just want some closure, and I don't care about the job anymore.

I'm mainly looking for a way to understand how another candidate completed this, when it is in fact impossible (I'm happy to cite documentation to prove that fact). I have been losing sleep over this, because I simply cannot wrap my mind around it.

I feel like I need closure, but the employer is not explaining this test result to me.

What are good ways to learn from this and move on?

For those interested, the code was (in C):

void functionToWrite(int[] a){
    //your code here
}

int main(){
    //DO NOT CHANGE THIS CODE
    int a[];
    a = gets(stdin);
    functionToWrite(a);
}
  • 1
    Comments are not for extended discussion; this conversation has been moved to chat. – Mister Positive Nov 19 at 12:11
  • 3
    This question is being discussed on meta with the goal of re-opening: workplace.meta.stackexchange.com/questions/6440/… – dwizum Nov 19 at 17:23
  • There was a comment or answer on this question that had to do with the test question possibly being from CoderByte. Was it deleted or removed? If so, why? It was informative to me. – Kodos Johnson Nov 22 at 20:15
  • @KodosJohnson Agreed. I made a comment on the answer to that question as well, stating that the hack which was intended to alleviate confusion only caused more. My comment was also deleted – Brydon Gibson Nov 22 at 20:19
  • 2
    Just to get the technical side out of the way: This code is likely from the testing site CoderByte. CoderByte uses the gets function in a very peculiar way, which is invalid in C and C++, so this is expected. See What is going on with 'gets(stdin)' on the site coderbyte? for details. – sleske Nov 25 at 8:17
79

You said,

I don't know what to do here

The best thing to do is probably to move on. Focus your mental and emotional energy on other opportunities.

Either:

  • The employer is right - the test is not impossible, and you just screwed it up. But if that's the case, following up won't really get you anywhere, because they've clearly passed you over at this point.
  • The employer is wrong - the test is actually impossible. Even if you prove them wrong, they're not going to suddenly change their mind and decide to hire you.

In other words, pressing them for an answer doesn't change the outcome. And, ultimately, job searches are about outcomes. There's really no point in trying to make a point and nothing to really be gained from any goal other than either getting a job, or not getting a job.

You also said,

I just want some closure, I don't care about the job anymore

The thing is - as harsh as this may sound - the employer is in the business of filling their vacancy, not granting closure to a random person who they didn't select. Job searches are about filling positions, not about feeling good. The sooner you realize that, the sooner you can move on.

If you're worried about potentially missing an opportunity to learn something about how to do the test, or the technical skills required to pass tests, you'd probably be better off in self-directed studies (or enroll in classes or training) versus getting hung up on one single employer's questionable test. And if you really are truly hung up on the actual technical question in the test, and you feel like you need to resolve the technical issues in the question, you would probably be better served working out your frustration in a way that doesn't involve the employer (write a blog post about it, ask questions on a technical forum, etc).

  • 9
    > getting hung up on one single employer's questionable test. I think this is where I am struggling. It seems from the answers here that time and forgetting about it are the only way to move on – Brydon Gibson Nov 18 at 19:01
  • 8
    @BrydonGibson you could write a blog post explaining how do you think the test is wrong, and still trying to solve it. Just don't mention any names in it. This may help with the closure. – Tymoteusz Paul Nov 18 at 19:11
  • 4
    @BrydonGibson, Sometimes, potential employers lie. You need to understand that. – Stephan Branczyk Nov 19 at 6:48
  • 4
    Also, consider the question "does the employer want to hire people who get hung up over trivial and irrelevant details or vague instructions about what to do?" (The answer is likely to be "no".) – alephzero Nov 19 at 11:59
  • 2
    +1 for "pressing them for an answer doesn't change the outcome" Brilliant answer. So many people forget that anything that doesn't change the outcome is a waste of time – Richard Says Reinstate Monica Nov 19 at 14:06
48

Open a question on Stack Overflow.

You might get some kind of surprise answer and then you'll feel dumb and move on. You might get a million veterans on your side telling you that you were correct and then you can just say "well, screw that company then" and move on.

Be sure to give as many details as you can.

  • Some sort of web-portal mechanism processed your code
  • What version of C were you expected to use?
  • Etc.
  • 15
    Seconded; given I don't even know what's so 'impossible' about shown code, as I don't know C - if anyone makes an SO, I'd be interested to look – OverLordGoldDragon Nov 19 at 7:33
  • @OverLordGoldDragon ditto, I would like to see more discussion on the code. Were they looking for people who would be able to isolate the error and work around it? – Konrad Nov 19 at 7:41
  • 3
    Check my answer below. Just treat 'gets' as a function that gives you your array and then ignore it. Working with foreign code without a full documentation should not stop anyone from working on the real task. – FooTheBar Nov 19 at 9:22
  • @FooTheBar I saw your answer! It's important, but I think it might actually have an even more practical meaning – Mars Nov 19 at 9:25
35

I think the test is valid and you failed it by completely focusing on the irrelevant part. Your task was (only!) to implement the 'functionToWrite'. The 'gets' function is a part of the system that someone else wrote and that you have an (implicit) documentation for. You see that this function gives you a list of numbers (and to compute the length of the list is the first part of your real task) and you should not care about the details of the implementation.

This is very similar to a normal working environment. You focus on your part of the task while using code that others have written. You should definitely not try to understand all of the software your company wrote before working on your job.

To solve the task, you should have treated the part as PseudoCode that simply gives you the list of numbers you should work on.

  • 8
    OP writes "it is in C" but I am wondering if the test actually stated "it is C". Not getting hung on seemingly invalid code may have been part of the test and OP rightfully failed. – Fildor Nov 19 at 9:40
  • It's also possible that the pseudo code in the example was written differently than the actual test code. – CramerTV Nov 20 at 2:18
28

To pass the test, you had to ignore the line that said DO NOT CHANGE THIS CODE. You didn't do that.

This left you with one declaration that just doesn't compile, and one highly dangerous line of code (google for "gets dangerous"). So the right thing to do and to pass the test was to ignore that line, rip out what was there and replace it with something that works safely.

  • 8
    The web portal used to write the test relies on gets. In fact, I don't believe it actually compiles the code but merely parses it. Changing it caused the test to fail – Brydon Gibson Nov 18 at 19:26
  • 31
    In other words this is a Kobayashi Maru exercise. Also void functionToWrite(int[] a) is not a C function definition. The int[] a reads as a C# definition. – Peter M Nov 18 at 19:43
  • 16
    Just to repeat: This is NOT the standard 'gets' function. It is something they wrote that gives you your array. The normal 'gets' returns a string, this function here returns a int[]. So all the documentation for the string-gets is completely irrelevant. – FooTheBar Nov 19 at 9:25
  • 14
    So your approach to "I don't understand this code" is "ignore the comment and completely rewrite everything" (thereby ruining the application). Yeah not sure that's the attitude people are looking for when hiring programmers. – Voo Nov 19 at 9:59
  • 7
    @Tomáš The first step when refactoring code is understanding said code. You should never rewrite code because you don't understand it, because well, how do you know you did it correctly? (Now in a real job if you don't understand the code, that's probably a sign that it requires refactoring or comments, absolutely. But if those are missing that still doesn't mean you should simply forge ahead - find someone who does or get into the weeds and figure it out. Tests help.) – Voo Nov 19 at 10:14
16

I don't know what to do here. It is driving me crazy

Your best course of action is to simply move on and forget about it. If the task is truly impossible then that is indicative of a company with unreasonable expectations for their employees. You should be thankful that you will not be working for such a company.

  • 3
    Indeed. The asker should try to separate their desire to "win" (the job) from their desire to work with/for these particular clowns who have now revealed their nature. – Chris Stratton Nov 18 at 21:15
13

The test contained invalid code [...] the webpage had glaring issues and refused my answers for one of the other questions [...] How should I help myself move on?

Don't just move on from this, take it as a learning opportunity. When presented with a less-than-ideal situation, your (potential) employer expects you to make the best of it.

There are uncountable professional software developers out there who rage every day against a homegrown "framework", left by a predecessor, which is hard to debug, hard to develop new features for and slow and inefficient as hell. Yet their employer can't miss the six months of downtime it's going to take to replace it, so you'll just have to chug along, improving what you can, when you can.

If you're going to be that developer who denies to fix a bug "because I've told you it's there before", or who is not going to develop a new feature "because given the constraints of the framework, I can't implement it in the way I envisioned it", then you're not going to be employed there for long.

You can make yourself invaluable by documenting what's wrong with a situation and offering improvement suggestions, while doing the actual work that's requested of you. Because that's what they pay you for.

If you want clean room / greenfield / research position where you can do everything the way you want, you'll have to search hard for rare positions that are highly competed for, and prove that you're worth the position.

This was the same situation. The potential employer chose a web application where they can offer their applicants simple tests that get checked by the application.

You probably copied the exercise to your own editor, your own compiler, and that one complained about non-existing functions - because those were specific to the test site! You should've altered the code so it compiled fine on your machine, and altered it back when submitting.

Would your code then have passed, you could have mentioned the problems you encountered along with your application. But by showing that you refuse to go with constraints that are there, you've showed the employer that you probably won't fit well in the way they work.

  • 9
    Good point - we used to give a coding test with conflicting requirements, and it revealed a lot about how people would react when the situation came up for real. – Robin Bennett Nov 19 at 9:33
  • 7
    @RobinBennett You're evil – Mars Nov 19 at 9:34
  • 1
    @Mars No, he's professional. And also, any nontrivial requirements are internally conflicting and incomplete. Documents are not correct, get used to it. – Volker Siegel Nov 20 at 0:42
  • 1
    The problem with having unclear/conflicting requirements in a (home) coding test are that it doesn't match the real world. In the real world, you would ask the responsible dev or your manager or someone who knows more about the problem. In a coding test, you sort of have to read the employer's mind whether they want to be asked questions or would rather you work around the problem on your own. On-site tests are better for this as there it's more obvious that you can ask questions of the supervising person or think out loud. – Llewellyn Nov 20 at 18:28
3

Technical answer here, but from the comments by OP:

The web portal used to write the test relies on gets. In fact, I don't believe it actually compiles the code but merely parses it. Changing it caused the test to fail

So it sounds like your code was actually run in some form and was not merely pseudo-code.

If your answer was meant to be a one-try answer, then I think it's possible that you were given invalid code so that you could not simply compile and run it on your own machine to check your answer.

By recognizing it as invalid code, you're either

  1. demonstrating great attention to detail, or
  2. demonstrating that you tried to run it on an external compiler.
  • They only did not include the implementation of their gets function. so it's 2.1: You compiled it and failed to mock (simulate) the missing function. – FooTheBar Nov 19 at 9:29
  • @FooTheBar There are a lot of other errors – Mars Nov 19 at 9:32
  • functionToWrite is C# notation, the array declaration is wrong too I believe, I can't remember the rest – Mars Nov 19 at 9:33
  • I never used C, but looks legit: stackoverflow.com/questions/6567742/… – FooTheBar Nov 19 at 9:35
  • 4
    @FooTheBar the positon of the [] is on the wrong side of a :) – Mars Nov 19 at 9:36
0

So many great answers here. This sounds to me like a OCD/Autism issue to me. The OP is hung up on the fact that the code cannot compile as is, because he is convinced that the untouchable code is what is actually run. But like others have said, it is more a pseudo stand in code, to get people to understand the gist of what it is doing and what kind of variable it is passing to your code, in this case it looks like an int array.

Basically they are testing your ability to quickly read code and guess/infer what it does vs actually dissecting to see what it actually does. They want you to just understand what you are given and to do what you asked to do with it. As if they are not asking for actual compiling code but pseudo code from you also, so they don't care about the actual language syntax as they are all similar to an extent but also different. They are testing your inference and logic skills...

But you failed by stopping at the first inference part. Sure this kind of test would exclude OCD/Autistic Genius level candidates, which can be a minus. But those are rare enough in and of itself. So my suggestion is to understand that the world sometimes doesn't test you in real life compatible terms, but sometimes in theoretical abstract terms.

-3

There is nothing saying do not modify the parameters shown int he function.

I think this represents an answer:

void functionToWrite(int* a){
    puts(a);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.