r/AskProgramming • u/wowbagger85 • Apr 19 '21
What would you ask someone to test basic programming understanding?
32
u/pf_bangs_303 Apr 19 '21
This is tough. The reality is it's very continuous. Two people can definitely have the title of software engineer, and one can actually add positive EV, and the other will be negative EV.
Asking someone a question will not be a good predictor of whether that person is positive EV for your business, and a lot of people are scam artists who essentially try to weasel their way into a job as a professional programmer, with absolutely no experience programming. I've even seen people go as far as apply to software engineering jobs and take virtual assessments, and pay for someone else to take the assessments. Assessments, and questions, can always be gamed.
The short answer is, other software engineers will quickly be able to know who is good and who is absolutely useless.
5
u/wowbagger85 Apr 19 '21
I'm just looking for some inspiration for questions. I agree with you, I know what I'm doing (well enough at least) so asking someone to explain a basic programming concept in an interview is a great way. I run a programming education so we have too many applicants to have long interviews. Looking for some good middle ground.
21
u/Icanteven______ Apr 19 '21
This.
When I was running my startup, I needed to hire a backend guy once we first raised some funding. It took us 4 months to find the guy. I personally interviewed over 50 people for the role, and that's after my cofounders had screened the obvious no-gos out.
Of those 50 there were 3 applicants that I got really excited about. They looked great on paper. I was pumped to see how they handled my technical assessment. All 3 were abysmally bad at figuring out novel solutions to a straightforward if not simple question. I asked them to write a program that would spit out all the valid Scrabble words that could be formed with 7 letters given those 7 letters and a list of all valid Scrabble words.
One of them was coding it out on Notepad...which is FINE if you're a boss at coding in notepad. He was not. It was painful. I cutoff the interview 20 minutes in.
Of those original 50 applicants btw, we gave 2 an offer, 1 accepted, and we had to fire them 4 months later because they weren't doing a good job. Hiring is HARD.
7
u/hugthemachines Apr 19 '21
Sometimes I wonder if you might as well just check so they know basic programming and then take the one you feel has a decent attitude and hope it goes well because it is so hard to really check how good they are. I was assisting in some hiring at our job and it was damn hard.
6
u/Icanteven______ Apr 19 '21
I think if you're looking to get someone more senior there's a lot more you can do. You can have architecture design sessions with them, give them assignments to figure out what tech stack to use given a set of constraints and grill them about why. You can dive deep into their previous projects to determine the bounds of their knowledge, and you can do die diligence finding people they've worked with in the past and asking them about what working with the person is like and what their weaknesses/strengths might be. All are data points meant to give you a stronger signal on the candidate.
1
u/plexxonic Apr 20 '21
Best interview I ever had was when one of the owners/senior dev and another senior dev asked me if I knew something particular (particularly involving C# lambdas), I said no several times.
They then presented me with a series of verbal questions and a whiteboard and asked if I could write the flow down, no actual code.
I was given an offer letter for senior dev within a week.
Even you if you don't know the technical details, being able to figure out a solution and then the details is very important.
5
u/AzurasTsar Apr 19 '21 edited Apr 19 '21
holy shit, I think I would fail hard at that problem if I had to do it on the spot. Just out of curiosity... what was the solution? Off the top of my head I'd think, immediately rule out valid words < or > 7 characters, and then iterate through each remaining word checking if any of the characters aren't one of the 7 from the input. Implementation details aside, I think that should work but it definitely wouldn't win me any points for time complexity I'm guessing
edit: also, maybe maintain some sort of map or honestly maybe a counting sort style array to keep track of how many of each character there is in the case of duplicates... but again that's additional overhead/complexity.
super curious about the optimal solution
5
u/Icanteven______ Apr 20 '21 edited Apr 20 '21
As another user already mentioned, a trie structure is useful for determining if a particular string prefix will be fruitful or would yield no valid words.
The other part of the problem is figuring out which strings you need to put into the trie to determine if it's a word/a prefix of a word.
This you can do by building all permutations of your 7 letters starting with all the single letter permutations, then all the 2 letter permutations, etc, all the way up to 7. As you build them, you can very quickly check using the trie if each permutation is a word (in which case add it to a set of valid words) or if it's a prefix of a word, or if it's neither of those. If it's neither, you can confidently disregard any future permutations that build upon that as a prefix, which prunes the scope of your search considerably.
Even without the pruning or the trie though, there are only about 6000 total permutations for 7 or less letters, and if you load up the whole dictionary in a hashset, you can just brute force it across every permutation.
2
1
u/SinglePartyLeader Apr 19 '21
Off the top of my head i would use a trie. It's basically a prefix search tree.
I could go into more detail with an implementation but that should be a good starting point if you want to solve it
2
1
u/Icanteven______ Apr 20 '21
Yep! It's definitely advantageous to preload the full dictionary into a trie.
1
8
u/maestro2005 Apr 19 '21
In what situation? A casual conversation? An interview?
6
u/wowbagger85 Apr 19 '21
Preparation for a interview, programming education. The course require basic knowledge like class, functions, if statements and such. Just looking for inspiration :)
13
u/YMK1234 Apr 19 '21
It really depends what you are screening for, but I would focus on problem analysis skills. I.e. give them a problem, and see how they break down the problem into classes. Maybe something that can be expanded upon. Like, we want to build this simple website, what do we do? Now we want to add this and that feature, how do we go ahead without ending up in spaghetti hell? And so on.
3
Apr 20 '21
This is tricky. One time we had an interview like this, i.e. asking how would a person break down a page view into components, and it went really well. However, it turned out that the person had basically almost no lower level knowledge, i.e. how to actually implement it - what are things like CSS selectors, how to write one, etc. You should test both higher level knowledge and lower level knowledge (and it depends on a job in terms of how much lower you need to go).
1
9
Apr 19 '21
I'd ask them to pair program w/ me.
6
u/TuesdayWaffle Apr 19 '21
This is a neat idea. Could you elaborate? Would you have them drive? Navigate? Both? What sort of problem would you work on? It seems a bit much to have them work on a real company problem without knowledge of your code base, but it might be fine if they were driving. But driving also doesn't really tell you as much as navigating does..
6
Apr 19 '21 edited Apr 19 '21
A bit of both driving and navigating, mostly informally like if we were on a team at a hackathon. We'd pick a small project or feature we are both interested and knowledgeable in and then just dive in. If after 20 minutes I don't feel like I'm extracting teeth, then I know the person I'm working w/ is legit. Most people are legit, but there are 2 specific people in my past (not from my current job thankfully) that I discovered were really bad when we did pair programming.
The project selection would be like "Oh you want to build <X> in the future, that is related to <Y> which I'm really interested working on myself. You know, the <XY> algorithm will be critical for both your <X> project and my <Y> project. How about we make a little progress on both our projects by hacking a prototype of <XY> together?"
Or to make it concrete, "Hey Robert, I know you have been building that ray-tracer in rust. I've actually been working on a voxel framework in C++. How about we work a bit on integrating your ray tracer into my voxel framework. It will give you experience integrating your ray tracer into existing projects and it will give my project a ray tracer with a maintainer I can pester ;)."
2
u/SpicyMcHaggis206 Apr 19 '21
My company had people pair on creating a List<T> object using primitive types and TDD. The applicant would drive and and the interviewer would just be there to give requirements and guide them when they got stuck.
It was usually the last step in the interview and just as much for the applicant to see if they liked pair programming because we paired exclusively on everything.
17
u/c3534l Apr 19 '21
I mean, its a joke at this point. But if you mean basic programming understanding then you should be able to do Fizz Buzz. I don't think its a good interview question or anything. But yeah, its a low bar to clear.
8
2
u/ayush_shashank Apr 19 '21
Well, this has to be the simplest.
Swap values (numerical mostly but even char in C) of two variables without using a built-in function or a third variable.
4
u/wowbagger85 Apr 19 '21
I would honestly have struggled with that one, but now I know :) it's perhaps a bit too clever.
5
u/ksblur Apr 20 '21
Am I allowed to use python? :)
x, y = y, xOtherwise,
x = x ^ y y = y ^ x x = x ^ y1
u/schlaubi Apr 20 '21
That's not basic programming, that's more of a puzzle question and would be a terrible solution besides in some very rare circumstances.
3
Apr 20 '21 edited Apr 20 '21
a := a + b
b := a - b
a := a - b
But I don't think this question is related to programming, it's more of a math question
Also it's not a practical question because you'd never do it that way - and if you do, you're not a good programmer because you're not writing readable code
I think there was only a couple of times over many years of programming when I had to swap numbers
1
u/ayush_shashank Apr 20 '21 edited Apr 20 '21
A math problem that you have to code and achieve efficiency.
It is space efficient and when you put it inside a function, it tells you what it does but you don't care how (black box understanding).
Although not at all recommended when swapping objects (including strings, depending on what language you prefer to understand what an object is).
But isn't all programming just math.
1
Apr 20 '21
that you have to code
achieve efficiency
I think this problem is too small to test your coding or code performance skills. It is space efficient, but the gain is too small to be worth it in any circumstance I can think of. In the times of Turing, when memory was a big problem, that would have been useful, but I think even the smallest devices these days have enough memory to be able to completely ignore this kind of optimization. Again, we might be gaining memory efficiency, but we're losing a lot more, i.e. code readability. I don't want to see any of my colleagues ever code like this.
1
u/ayush_shashank Apr 20 '21
My bad, the question is supposed to asked in a level wise manner..
"How do you swap two numbers?"
Use a swap method
"Without using a built-in method?"
Use a temporary variable
"Without using any other variables?"
a+=b; b=a-b; a-=b;
Now that's basic understanding of programming, you can't deny that, c'mon.
1
Apr 20 '21 edited Apr 20 '21
Does it test one's knowledge of loops? Conditional? Functions? Objects? References? Which are all part of basic understanding. This question only tests variables and assignment operator, but even more of math. This question is asked in the same manner as other programming questions, so it looks similar, but it's not a good question to tests one's programming understanding, in my opinion.
1
u/leonderbaertige_II Apr 20 '21
It doesn't work if both variables point to the same spot in memory. It takes longer to execute. And the space saved is not significant. I don't see the point.
1
u/ayush_shashank Apr 20 '21
How are the two variables pointing to the same memory location?
I do agree that space saved is almost insignificant, but it's still space saved with just basic math.
1
u/leonderbaertige_II Apr 20 '21
int a = 5;
int* ptr_a = &a;
int* ptr_b = &a;
*ptr_a = *ptr_a ^ *ptr_b;
*ptr_b = *ptr_b ^ *ptr_a;
*ptr_a = *ptr_a ^ *ptr_b;
Yes some space is save but in exchange for a 6-7 times (in my testing) increased execution time.
1
u/ayush_shashank Apr 20 '21
Yup, you overcomplicated it.
Honestly, I guess I'm making some sort of mistake here, but I'm somewhat confident when I say, you've used only one variable. But I may be wrong, it's been a really long time since I worked with pointers.
1
5
u/A_Philosophical_Cat Apr 19 '21
Personally, I've found pretty great success asking for two things: first, a short, damn near trivial programming problem. Not trying to test their esoteric knowledge of data structures or algorithms, just trying to make sure they can, in fact, program at all. You would be appalled at the number of people for whom something like "check to see if a magic square is valid" or something similar outs them as iincompetent Then, I ask them to describe something they've built and are proud of. Every half decent engineer I've interacted with can talk at great length about something they've built.
5
u/Roamin_Ronin Apr 20 '21
I’ve been developing for 15 years and the thought of interview questions always freak me out.
2
u/WankadoodleRex Apr 20 '21
Yep I have 5 years of experience at this point and I've yet to go through an interview where I've had to do something remotely similar to what I do on a day-to-day basis. I think it's nearly impossible to pass an interview without practising interview type questions outside of work.
8
u/myusernameisunique1 Apr 19 '21
The fizz bang game is always a good one.
Just write some pseudo code to play fizz bang.
Probably as basic as you could be
10
7
u/KaranasToll Apr 19 '21
What is a function?
7
u/ksblur Apr 19 '21
And following that, what is a method?
13
u/Korzag Apr 19 '21
now we're getting pedantic. Explain the differences between a function, a method, and a procedure.
5
Apr 19 '21
Functions and procedures are mostly used interchangeably, right? Are you talking about functions in the pure functional sense?
6
u/Korzag Apr 19 '21
Depends on the language really. In Pascal, procedures are void blocks of code and functions have return types. I was mostly being silly since there other things you could call what most folks would just call a method in the OOP world.
4
1
Apr 20 '21
Procedure is not a real thing as far as I know
2
u/Korzag Apr 20 '21
1
Apr 20 '21
Fair enough. I'm glad there's a push to reduce the amount of things in modern programming languages. IMHO if you already have a function, you don't need a procedure.
5
0
Apr 19 '21
[deleted]
8
u/ksblur Apr 19 '21
You don't need to use it every day to know what it is. OOP is part of every compsci/soft eng program I've ever seen.
Even if someone is self taught, they should have enough experience just living in the world to understand a very basic term like that. If they don't, it would make me think they also don't know about other basic terms (eg "REST API" or "hash map" or "stack")
2
u/MintChocolateEnema Apr 19 '21
That's petty. What is a struct in one language is an object in another. Same with "prototypes" and declarations. Method, Function, Member, Field blah blah blah.
I don't expect someone who works primarily in Javascript or Python (entirely in a separate paradigm from OOP) to understand OOP.
Please tell me you don't truly believe all programming languages share the same philosophies.
Moreover, I don't automatically assume someone understands the principles of any paradigm just because they "know what it is, despite not using it everyday".
Lastly, it is a very poor assumption that:
if Person A does not know the proper/formal name for some structure or concept in any language, then Person B shouldn't think Person A knows of other "basic terms".
That is ridiculous.
3
u/BigPimpinAutist Apr 20 '21
Well said, and very true. Seems like the definitions are getting so blurred these days that the original meanings and/or definitions are all but a hazy memory anymore.
1
Apr 20 '21
I can think of about a billion ways to answer that question depending on a context and a level of detail that you want.
1
u/KaranasToll Apr 20 '21
That is why is it a good question to guage someone's skill level.
2
Apr 20 '21
To be honest, if there's a billion ways to answer the question, that means that there's a higher chance a person with little programming skill may be able to answer it. I don't think one single question can elucidate the whole depth of one's programming understanding.
2
u/KaranasToll Apr 20 '21
What is important is how it is answered. I don't think a single question is enough either, but it is what the post is about, I'm just making a small contribution.
2
Apr 20 '21
I do think it's a good question to gauge one's level of clarity. The answers may be very creative and range a lot, so you may be able to see if they choose a very clear and straightforward way of describing it.
5
2
u/knoam Apr 19 '21
Here's some code, what does it output?
Maybe something that requires knowing the modulus operator and that array indexes are zero based.
2
u/Lakitna Apr 20 '21
I had to help hire for a front end dev a while ago. Junior/medior position for an Angular project. The most useful question turned out to be "what is your favorite Javascript dialect?".
Any answer was fine by me, but too many applicants just didn't understand my question. Which to me is an indication that they don't follow trends in the field and they might not have their hart in it. I used more questions to verify those assumption of course.
1
Apr 20 '21
What do you mean by "Javascript dialect"? In my 5+ professional years as mostly JS dev I've never come across this term. Also, a person may be passionate about JS and not follow the same trends as you, so, to me, it's not an indicator.
1
1
-2
Apr 19 '21
for the SW position role, I think it is better to give a full-fledged a small task to build from scratch and then deploy it instead of some DS question(unless your project is more precisely requirement). this way you can understand his knowledge, how he structure, do he use git or not? how he is good with unit test case,and deployment etc. what i he able to understand what kind design pattern he is using and so on.
but in my opinion, an assignment is worth more than a DS test.
5
u/KingofGamesYami Apr 19 '21
I disagree strongly with your idea. The time investment for the applicant is too high, you'd be discouraging qualified candidates.
0
Apr 19 '21
Don't u think, this is much better then writing a ds program which requires certain logic and u are not able to complete in time with few cases left? Isn't he the qualified person left this way.
My suggestion I find is much better as it eliminates scripter and allows inclusion of people who are familiar with design process and end to end development
6
u/KingofGamesYami Apr 19 '21
No. The majority of developers would just go to a different company rather than putting up with your lengthy test. The remaining developers would be those desperate for a job because other places won't hire them.
Do you really want to hire developers that other companies would not? Even if they meet your bare minimum standards for technical ability?
1
Apr 19 '21
Idk what is your country hiring process, but this is here in mine, without a test you can't.plus if other companies is not hiring a person is not my problem if that developer is fullfilling my criteria why not. I would hire him for his coding ability not for increasing my gender quota or other things
2
u/KingofGamesYami Apr 19 '21
Typically the way it works in the US is you have 3-4 hours of interviews, then you're hired. The first couple months are essentially a trial period, if you don't work out they just fire you. Since we have at-will employment technically they can fire you at any time, but after a few months it's very unlikely (unless you do something really stupid like stealing from the company).
There are places that have extensive tests, but, they are mostly very large companies that have an acceptance rate of like 0.01% of applicants. So they can afford to be very selective and will still get very good employees with this method, because people are willing to go the extra mile for them.
2
Apr 19 '21
i think, different country has different set of criteria. i am in india, here you have to generally go through the coding round first, need to complete all question, then comes the technical round.
my saying about how person create a project, or make a simple end to end thing, come from the fact that, being in a small team a person need to do understand the end to end process and able to catch up quickly, which is find DS round not provide much.
2
u/snugghash Apr 20 '21
I think it's mostly that India is a hiring manager's market, no matter how many hurdles you put down, if every company does it you'll get decent candidates. Other places have far fewer engineers and so need to make it easy for engineers/pay them a lot/be otherwise desirable to work.
1
u/SpicyMcHaggis206 Apr 19 '21
If the dregs of an applicant pool meet your criteria then maybe you should raise your bar.
1
3
u/AspirationallySane Apr 19 '21
I’d walk away laughing, and I’m a damned good programmer.
You want me to waste how many hours of my life on some stupid task on the off chance I might find your problem space interesting and your team compatible?
AllTheNope(TM).
And that’s before we even get into the probability that you’re pretending you have a position to get free work from suckers.
0
37
u/VirtualLife76 Apr 19 '21
Depends on the language, but 1 of my basic interview tests was to write a random password generator. Would weed out 90% of the candidates. Some would write 100 lines of code in an hour most around 50 and it still didn't work. The good ones wrote 1-3 lines.
Basically just a simple logic test of how you think.