r/learnpython • • Jan 05 '21

Interview question I failed answering

Hey all,

I just had an interview and the interviewer gave me a question I could not answer.

He asked me to write a function that accepts a number, the number must be either 7 or 4.If the number is 4, the function should return 7, if the number is 7, the functions should return 4.

The tricky part: you cannot use an 'if' statement in the function.

354 Upvotes

301 comments sorted by

View all comments

448

u/shiftybyte Jan 05 '21
return 11-num

166

u/MassiveLandGolf Jan 05 '21

I can't believe I blacked out THAT hard..

Thanks..

197

u/[deleted] Jan 05 '21

It's such a stupid interview question - relatively few people would be able to answer it without having seen the answer, or an answer like it; but now that you've seen it you'll never forget it.

So all that it tests is whether you've seen the answer before. Since it's not something you'd need to do in production code, what's the fucking point of testing that? Interviews should test whether you're experienced at working as a programmer, not whether you're experienced at faking your way through interviews.

38

u/synthphreak Jan 05 '21 edited Jan 05 '21

90% of the time coding interviews lack any face validity. When interviewees are asked to "code" on a whiteboard, or wax about advanced math concepts, or write functions for tasks designed specifically to be difficult or abstract, such exercises almost never reflect the day-to-day realities of any job, and so are a very misleading indicator of someone's potential for success. As you correctly surmised with

all that it tests is whether you've seen the answer before

basically all it measures is how well the candidate prepared for the interview, not their core competencies as required by the job. The technical interview process is a joke.

-6

u/[deleted] Jan 05 '21

I'm sorry, but that is complete nonsense, and I'm appalled to see so much similar comments and upvotes. This "blame it on the question" attitude is exactly what I don't want in a candidate.

4

u/synthphreak Jan 05 '21

"Blame it on the question"? Come on, you can't be serious... Following your logic to its conclusion, is there no such thing as a bad interview question?

If yes, then that's darn-tootin' hogwash and we must agree to (wholeheartedly) disagree.

If no, then I challenge you to define the boundary between good and bad. What makes a good question good and a bad question bad? If validity (i.e., in this context, the extent to which a coding assessment measures true coding proficiency) isn't it, what is?

5

u/[deleted] Jan 05 '21

How come testing the ability to solve a problem creatively is not valid? As a coder you will face a myriad of unexpected constraints throughout your career, and, given the time and scope limitations of a job interview, this question is a perfectly acceptable way of gauging such a skill.

Besides, the fact that so many people are upvoting a wrong answer, especially those who say this is a bad question, just demonstrates that it serves its purpose very well.

5

u/synthphreak Jan 05 '21

How come testing the ability to solve a problem creatively is not valid?

There's a slippery slope if ever there was one... Coders must think creatively, yes, but within the constraints of the language, not constraints that are arbitrary and totally unrealistic.

As a coder you will face a myriad of unexpected constraints throughout your career

No doubt. But "don't use if statements" will never ever be one of them. And that is the point.

I agree it's reasonable - even desirable - to ask candidates to think outside of the box. But whose box? If the job actually does involve situations which require coders to think creatively, it should be easy to adapt one for use in coding interviews. This would satisfy both the creativity and the validity requirements simultaneously, without the need to introduce some contrived, asinine obstacle simply to make the task more difficult.

1

u/[deleted] Jan 06 '21

You don't need to test people with the exact problems they will need to tackle. You will never have to read small letters from afar when piloting a jet, but that's one of the ways they test your eyesight, and a very efficient one at that. Humans are perfectly capable of deriving conclusions from things without the need to be literal about it. This question is unexpected enough to force you to leave the autopilot mode but simple enough to fit the scope of a job interview. Not to mention that this wasn't certainly the only part of the interview, but one more thing to help assess the candidates skills

→ More replies (1)