Show HN: 15-question programming quiz with answers
quiz.triplebyte.com
quiz.triplebyte.com
This isn't a generalist quiz, nor is it a good baseline for interviewing candidates for the hiring process, this wouldn't tell me anything about the application of their skillset.
It basically relied on this fact...
x = 256
x is 256 # True
y = 257
y is 257 # False
Which for one, you shouldn't use `is` to compare integers in Python. I wish I could have just written that as my answer.Secondly, you need to be aware the CPython uses an integer cache which causes the answers to be different. You'll actually get different answers based on whether you run it as a file, enter it line-by-line into the interpreter, or use a different implementation such as PyPy.
https://stackoverflow.com/questions/15171695/whats-with-the-...
There wasn't any point to the quiz, so it's okay that they put in silly questions like that. But it's clearly there just to try and trick you, and not quiz you on anything relevant. Most of the other questions were tricks of the sort, or or Python 3 specific gotcha's.
I wouldn't expect anyone else to know it, and don't consider it something positive or negative as far as programming skill is concerned. It's kind of related to interest, but admittedly I waste a lot of time playing with stupid details like this in programming languages, so maybe it actually makes me less productive than the average person.
[0] "Write a program that makes 2 + 2 = 5"
https://codegolf.stackexchange.com/a/28851
edit: wording change
Knowing fb, there might well have been; if they had a facial recognition webcam up and noted applicant scores no one would hear about it. They'd probably just call it an "experiment in hiring"
By the way y == 257 does work.
>>> x = [1,2,3]
>>> y = [1,2,3]
>>> x == y
True # two lists with the same values; equal
>>> x is y
False # two different lists; doesn't matter that they contain the same values
>>> z = x
>>> z is x
True # same list object in memory
Because here you want to know if the two integers are logically equal, not if they're necessarily the same object in memory, you want "==" and not "is". Due to an optimisation, "is" might work for small integers, depending on implementation, but the takeaway is not to use "is" for value comparisons; that's what "==" is for.-5 to 256 (inclusive) [https://github.com/python/cpython/blob/master/Objects/longob...]
Given this, the expression "1" on the current version of cpython returns the same object from the small integer cache every time. Not just an equal object, the very same object. Overall, don't depend on it - it's an optimization and can change all the time.
-5 to 256 (inclusive) [https://github.com/python/cpython/blob/master/Objects/longob...]
I actually didn't catch the trick until I asked someone later if they had gotten the same problem twice, "Almost, but the values were different" which is when I realized it (I blame the beer during opening night). However, as I found out today, because the way they worded the question it was all on a single line (if I remember correctly). So both cases should actually have been True, and I was right both times :P
> (e.g. does pypy do the same? ironpython?)
I wasted... ahem, spent a few hours today playing with this and found a few things, it's pretty neat!
In PyPy, `is` will always be True for primitives. This also means NaN is NaN (but still never == NaN). It doesn't use memory location for things like id() like CPython does, but it guarantees you get a unique representation. [0]
In CPython (3.5.2), it will always cache [-5, 256]. Here's the code that creates that array at startup [1] and each possible init/copy function calls this first to see if it's a cached int [2].
But it can sometimes cache other values! It also depends on if you do it from a module or the repl, and it's different depending on what scope or line each name/value is on. This one weirded out some coworkers, all from one continuous repl session:
>>> x = 500
>>> x is 500
False
>>> x = 500; x is 500
True
>>> def wat():
... x = 500
... return x is 500
>>> wat()
True
>>> x = 500
>>> def wat_wat():
... return x is 500
>>> wat_wat()
False
If you run it from a script you instead get True, True, True, False. You can disassemble it to get a hint at why. One uses STORE_FAST and LOAD_FAST, and the other LOAD_GLOBAL. >>> disassemble(wat.__code__)
2 0 LOAD_CONST 1 (500)
3 STORE_FAST 0 (x)
3 6 LOAD_FAST 0 (x)
9 LOAD_CONST 1 (500)
12 COMPARE_OP 8 (is)
15 RETURN_VALUE
>>> disassemble(wat_wat.__code__)
2 0 LOAD_GLOBAL 0 (x)
3 LOAD_CONST 1 (500)
6 COMPARE_OP 8 (is)
9 RETURN_VALUE
Now I'm still trying to figure out why STORE_FAST and LOAD_FAST cause it to use the same object, and why those only get called when it's interpreted together. When I figure this out I might put together a longer post about all this.Also don't use `is` for comparing integers. ;)
[0] http://doc.pypy.org/en/latest/cpython_differences.html#objec...
[1] https://github.com/python/cpython/blob/master/Objects/longob...
[2] https://github.com/python/cpython/blob/ba85d69a3e3610bdd05f0...
Also see the global case:
In [2]: x = 500
In [7]: def wat_wat_wat():
...: global x
...: x = 600
...: return x is 600
...:
In [8]: dis.disassemble(wat_wat_wat.__code__)
3 0 LOAD_CONST 1 (600)
2 STORE_GLOBAL 0 (x)
4 4 LOAD_GLOBAL 0 (x)
6 LOAD_CONST 1 (600)
8 COMPARE_OP 8 (is)
10 RETURN_VALUE
In [9]: wat_wat_wat()
Out[9]: True
But this only goes further to prove my point - it's a bit of a silly question to quiz someone on :-) For one the question didn't seem to be well defined enough, but also it tests something that no one in their right mind would do, and also I don't know if the authors realized these nuances themselves either. I guess it makes for good trivia.Also wat! The bytecode for the global case makes sense, but I wasn't expecting True?!
- Reference semantics for pretty much everything, except perhaps basic types such as integers - but those are generally "immutable" (e.g. no 5.add(6) mutating the "original object" in-place) making by-reference vs by-value moot.
- Arguments copy the reference, they do not alias the original reference.
- Mutating functions, if the return value isn't being used, are either being misused (e.g. the code has a bug) or mutate the original object in-place.
- Closures alias the same variables
This could be JavaScript, ActionScript, Ruby, Powershell, Squirrel, PHP, ... hell, even a lot of the compiled statically typed languages share similar semantics. I'd expect someone coming from, say, a pure C/C++ background to have some trouble though, which is perhaps the point you're getting at.
I believe that it tries to be a bait and rubbish filter at the same time.
For a few questions, I also just booted up my Python shell, rather than comprehending the script. :/
It would have been helpful if each question had the relevant language specific information - for example, reference/value semantics.
The problem is that the function makes no frigging sense without the argument being a reference, so you're naturally forced to assume that it is.
that being said. Some remarks about questions:
1st fails for all NaN/empty. Returning negative infinity is hardly a good choice for an array full of NaN.
2nd I didn't like this one: "children" comes from nowhere. There is no 'definition' of order, so 'first' is quite confusing, perhaps 'any' suits better.
5th I'd have expected white spaces in the toString rendering of the array (checked via inspect element). Had to make some assumptions.
7th since only variables i1 and i2 are defined and 3rd/4th answers make no sense as loop predicates, the entire merge function body is rather pointless.
8th About the correct answer:: One problem with ASCII is that it only support English characters (and a few other European languages). The characters are Latin and even Ural based languages like Estonian/Finnish/Hungarian use the same base for alphabet. "Unicode is like ASCII, but larger.", I'd never consider them a"like", for instance converting hexdecimal numbers to their asciis code is 5byte assembly for 8086. Also ascii is sort of a code page while unicode tries to combine all code pages together.
10th But because they share memory with other threads in the same process, threads must synchronize access to shared data to maintain data integrity. "Synchronize access" implies certain data model/locking paradigm. It's possible to have entirely lock free/copy-on-write multithreaded code that will exhibit no need for explicit synchronization. Alternatively some code could still be correct with benign data races (but that usually comes close to poking the dragons)
11th best practice is generally to use prepared statements, which lets the database itself protect against SQL injections. The statement is not necessarily true, the prepared statement could be just standard execution with parameters being escaped by the database driver (client), technically still performing the escaping part.
12th Side channel, timing attack is correct but virtually impossible to observe due to the very short nature of hashes and the fact they are all in the L1 by the time the check is performed -- even SHA512 is just one cache line, processing the comparing function yields 10ns or so time difference. The real concern is "the user_submitted_hash" -- users should not be submitting hashes directly as that precludes salting and invalidates use of any =slow= hashing function as the attacker just submits more hashes. IMO a bad question.
14th One advantage of DFS, however, is that it uses much less memory. BFS must store a queue of nodes to visit, and this queue can grow to (order) the size of the entire graph. The statement is not universality true and the worst case scenario is the same, a good answer https://cs.stackexchange.com/a/299. More importantly DFS can be executed in parallel.
I started reading the green part after first few answers, hopefully the remarks are useful (and not snark).
queue.extend(node)
queue.extend([node])
queue.extend(node.children)
Sure, I could take a guess which one of those appends the contents of "node" to the end of "queue", but I'd be guessing about syntax, not programming.After that, and question 3 about what happens when you assign to a function argument, I realized it was a Python quiz and stopped reading.
From a python-specific viewpoint, dequeue.extend appends a given list to the end of the queue. The first example will raise an exception, but the other two are perfectly valid, and their behavior isn't special to python - it's just asking whether you'll want to vi it this same node again, or the node's children.
Incidentally, it's not as if there's any standard library 'node' class with a children method. This was a structure they defined, but did not share the definition of.
Ahh, that makes things much clearer. Since they weren't otherwise mentioned, I supposed that "value" and "children" were properties of some existing Python collection object - and that the question was asking how "queue.extend" expected that collection to be passed in.
I guess this is the inverse of a language-specific question - if one knows that "children" has no significance in Python then I suppose the question would be clearer.
# assume "node" is an object with "value" and "children" properties
would make this question clearer.I've been a software developer for over 4 years but I don't have a formal CS education. I've gone through CLRS along with MIT's open-courseware--but I rarely use any of that directly in the workplace and so have forgotten a lot of it. And I think I'm a pretty good software developer, yet in the past when I've tried to get into Hired or Triplebyte, I always leave feeling like I don't belong in this profession because I can't tell you the big-O complexity of DFS off the top of my head, much less write the algorithm on a scratch pad.
I've been doing technical interviews for a few weeks now (I was recently laid off) and I'm honestly just a little tired of the brain teasers and non-applicable algo questions--and more often than not, the interviewers flexing their "knowledge" muscles.
Case in point: I'm in final stages with multiple companies for a Rails position, yet only one of those had even mentioned Rails in the technical interviews--the others decided to quiz my CS knowledge and one of them even quizzed my FP knowledge (for a Ruby position…). I don't understand it.
I am sorry that our process makes you feel bad :( The simple truth is that there are a lot of different ways to be a skilled programmer. One ways is being really good at CS (and to people who want skills in CS, talking about DFS is a reasonable low-bar question). However, another way is writing great, well-structured rails code. We work with people all the time who don't have CS backgrounds (we help them get jobs at companies that don't care about CS). The intent of our process is to measure both CS and practical skills (we actually break it down on more axes, but you get the idea).
This does mean that if you go through our process, you will be asked CS questions. But you'll also be asked to code. And not knowing the CS questions is not an obstacle to passing.
Are they not different skill sets? One is a practical skill, the other an academic one.
I've met "programmers" who had depth of theoretical knowledge but couldn't code their way out of a paper bag.
I've watched online lectures where Doctors of Computer Science lecture about OO but clearly have no understanding of what works and what doesn't.
I will concede that being good at CS will give programmers an advantage in solving problems in a subset of domains.
I suspect I could add the word small to advantage and subset and that statement would still be true.
Isn't the problem more often that lacking awareness of theoretical CS issues can limit your potential as a programmer? For example, someone with that awareness would immediately recognise some of the later questions as standard graph theory problems and could then solve them appropriately. Without that context, maybe a good programmer could still figure out a working solution from first principles, but it would surely take them longer. And while I don't suppose many of us will be working on intergalactic transport infrastructure any time soon, similar recognition scenarios do come up in plenty of day-to-day programming jobs.
I definitely agree that general CS knowledge is highly beneficial (it's why I put in the time to learn), but knowing implementations for specific algos doesn't seem as important in the day-to-day as interviews make it out to be.
Personally, I doubt that many people are walking around with the deep details of Dijkstra's memorized and readily available, unless they have a job that very specifically focuses on graph operations and they do nothing else day in and day out. So you could memorize it just for the interview, and then forget it again by the next day. But is there really any point to all that?
[1]: https://www.google.com/search?num=30&q=graph+algorithm+libra...
Fair enough.
My point is that you can gauge somebody's knowledge without making good software developers feel inferior e.g. by asking them how they would go about finding a person's likely connections given some weighted data for an imaginary social network. And then you can maybe get responses like, "That's a good question--I've dealt with that before when I was working on X, Y, Z and ended up using weighted graphs according to how many friends a person had in common …" or "I'm not entirely sure on the exact algorithm I'd recommend, but that sounds like we would set up a weighted graph and go from there …".
Rather than making talented people feel stupid, you encourage conversation. But what do I know, I don't interview people every day so take what I say with that in mind. I just think tech interviewing is broken. I'm always left frustrated and my excitement to join the team dies down due to thinking I won't fit in because I'm not "smart" enough.
He literally says that one way to be a skilled programmer is to be really good at CS. How is that not magically? What word would you have used?
Unfortunately, your reply is clearly condescending. And adds nothing to the discussion.
> I suspect I could add the word small to advantage and subset and that statement would still be true.
I doubt that's even close to true. You need CS knowledge to optimize programs and to design reliable services. It would only be true if you squint really hard and cherry pick some domains where CS knowledge isn't valuable and cherry pick what counts as 'academic CS knowledge'.
I would have edited my previous reply, but it was too late.
I'd like to see you design and program a P2P networked program without any CS knowledge, like Kazaa or Bit Torrent, that actually works as well as they do.
> I've met "programmers" who had depth of theoretical knowledge but couldn't code their way out of a paper bag.
That's true for lots of fields, but it's not hard to see that that doesn't mean theoretical knowledge isn't useful.
Honestly, even though I do know a fair bit about the Bit Torrent algorithms, I wouldn't trust that knowledge since it's most likely out of date or incomplete. It's deserving of research for anyone, even people who 'know it already'.
That's why I don't understand these narrow algorithmic tests - very, very seldom is a priori knowledge about DFS vs BFS going to be something that makes or breaks a project.
It would be akin to testing civil engineers on the memorization of precise ratios of the ingredients of concrete in current usage, instead of on the broad applicability of particular materials to particular purposes.
1. a programmer without any formal CS training
2. a CS graduate without any practical programming experience
Most programmers without CS degrees would pick up the concepts needed in a few days, most CS students would take months to even be able to finish a basic program. And it would fall over as soon as you sneezed at it.
While there will be exceptions on either side, run that race a thousand times, and the programmers would win the majority of times.
But to run with your new scenario, professional programmers could come up with just a working solution quickly. However, lots of CS students could do the same. Pretending like no CS students can program reasonably well is disingenuous.
> most CS students would take months to even be able to finish a basic program
I don't have statistics on that, but I suspect most seniors and juniors could get something working in far less than a month. You're just trying to paint them in a worse light here. It's not like CS students don't have larger projects they complete in relatively short time frames.
> And it would fall over as soon as you sneezed at it.
I bet the that would be even more so for programmers with no CS experience. The reason I mention P2P programs is that they require CS fundamentals to function reasonably well. And CS students would be far better equipped to look up and understand and implement those things. Your average programmer who thinks CS is unnecessary is likely to write something that indeed 'falls over as soon as you sneeze at it' here because under a real load, it will not perform well.
> While there will be exceptions on either side, run that race a thousand times, and the programmers would win the majority of times.
For writing yet another Rails website or somesuch, maybe. For an example like mine, that requires in-depth CS knowledge, not a chance! I think the reason you are so confused is that you assume CS students can't be 'programmers' and/or you're mentally pitting experienced devs against new CS students. I doubt a new programmer that didn't have CS knowledge would do well at any of this!
I doubt most CS grads could do this. One hard part of it is the p2p (but that's already been solved [0]). Having a project that large where you don't eventually shoot yourself in the foot because of architecture and finish in a reasonable time without using too many resources on a user's computer is also a hard part.
Of course not, but the point is that the information can be valuable for making real things.
Sounds like you're only familiar with programming to solve easy problems. Lots (most) of us do it, and that's fine, but there are a large number who tackle the more complex domains and need both skills.
You are, after all, agreeing with me. Most.
I mean, what do you guys do, just walk in and wing it?
Ok, so I generally do research about the business to make sure I understand the problems they are solving and have good questions to ask, but never CS interview prep. And I'm not some coding genius...I couldn't rattle off big-o for any algorithm off the top of my head, for instance...maybe a little above average.
Then again, I've only worked for 5 employers in a 19 year career. I think that was something like 18 interviews total in my career. A grand total of 1 or 2 required any deep CS knowledge and those were questions like "write fibonnaccci on the whiteboard*" or write a linked list in a code editor. I don't consider those to be worth studying...you should be able to do those off the cuff. And also, I'm pretty sure I can come up with a reasonable solution to most problems presented under pressure...something I know throws some people off.
Anyway, those 18 interviews yielded something like 9 or 10 job offers. And the fibonacci one...no offer...stared at it for 5 minutes after getting stuck on one of the conditionals before finding my mistake and didn't get the job. But whatever. There are always more interviews.
Now, I've also never approached a job like "I really want to work at Google/Apple/Facebook/etc so I have to ace this interview". I've always taken a broader, more laissez faire approach to try to find the right fit for me. So it might just be a matter of your approach to a job hunt.
This comment[0] says it better than I can:
unless you're interviewing at one of the big companies with a known interview process, you'd basically be wasting your time.
I've done hundreds of tech interviews over my career, and especially in recent years (now that companies are trying new things), it's completely random.
Some will do "Cracking the coding interview" type shit, some will do code reviews, some will give you a take home thing you have to present, some will do pair coding. Some do algorithms only, some do design discussions only, and so on and so forth.
So any prep I do will be a shot in the dark and 99% of the time I'll have to do something I did not prep for. So I don't bother trying.
Notable exception is my current job, which is a big tech co with a semi well known interview process (not as infamous as google or facebook, but still), and they gave me a fair amount of info up front. I also -really really really- wanted to work there because the team I wanted to work for did things no one else does. So i bit the bullet and studied/practice.
That was literally the first time (and probably last) time I did.
I know I'm a good programmer, and I got nearly every python-specific question wrong. I understand closures and call-by-reference tyvm, but I don't remember or care about the quirks of python.
Triplebyte in particular seems to not care about the difference between "good at programming" and "good at programming in python". The skillset needed for C, python, clojure and JS are wildly different. They do a disservice to their users by pretending otherwise.
I caught 3 "Whoops sorry you missed a weird bug in a specific programming language that you weren't explicitly being tested on". Sure, if I was doing a Python3 quiz, I'd expect those. But this wasn't what the quiz claimed to be.
Turns out, the "fill in the blank" code was easy, got all of them. Along with all the 1st year theory questions.
You ask dev about aspects of the language that are essentially memorization:
Does matrix.append(x) in python append by reference or by value? Both are equally likely without knowing anything about the language.
the question is also pretty easy to answer correct IF I know that, but I have no reason to know that. You're not testing skill in any sense of the word. You're purely testing familiarity with this specific language (and worse, this language's standard library)
That's bad.
I don't think they're equally likely. The question would have the same answer in Javascript, Ruby, Lisp, Perl 6, Java, and many other languages. You can see from the code samples that Python is a high level, dynamic, imperative language, so I think it's fair to assume you would expect that behaviour from it. There's a bit of guessing, but you can make an educated guess.
What JS/Ruby/Lisp/Perl/Java do is irrelevant. Hey, C/Go/D/C++ would all be more likely to append by value, but neither of us care a whit because it's asking about Python, which I know nothing about.
So (and this is really hard) try to forget that you've got experience with the language, and approach it as a random pseudo language: this question has no clear answer, because it depends on the memorized implementation details of the standard library of a language...
That's bad.
---
Finally: JS doesn't have matrix as a base type (boolean/number/string/null/undefined/symbol is it, baby), so for this same question, I'd strongly argue that you're simply wrong about bucketing JS with those other languages. Again, for JS the question would revolve around the implementation details of the matrix object and its prototype. Trust me, I can write a useful matrix implementation that appends by value in JS.
I guess my point was that you should be able to infer that Python would be more likely to behave like JS/Ruby/Lisp/Perl/Java than C/Go/D/C++. If you know or can tell by looking at it that it's much more in the first camp then the second, then you should be able to guess. You're probably right that I overstated how easy that is to tell just from the syntax if you don't know anything at all about Python, but it's also pretty short of memorizing implementation details.
> Finally: JS doesn't have matrix as a base type (boolean/number/string/null/undefined/symbol is it, baby), so for this same question, I'd strongly argue that you're simply wrong about bucketing JS with those other languages. Again, for JS the question would revolve around the implementation details of the matrix object and its prototype.
The 'matrix' in the question wasn't a special matrix type, it was just a list of lists. Word-for-word translated into Javascript it would look like:
let matrix = []
let row = [0, 0]
for (let i = 0; i < 2; ++i) matrix.push(row)
matrix[1][1] = 1[Block of code]
1. 34
2. 17
3. 43
4. 22.5
5. Not listed
____________________This would be a much more clearer way of handling pass by ref/value. 2 of the answers are correct, so this could be reused to ask the other one. If they're being tricky, they can award half-credit for choosing the wrong pass-by-*. And 3 other answers are junk. And this abstracts out any sort of programming neologims or fetishization of $random_language.
Here are the rules for JS, which I happen to know, because I use it often:
1. Javascript is always pass by value, but when a variable refers to an object (including arrays), the "value" is a reference to the object.
2. Changing the value of a variable never changes the underlying primitive or object, it just points the variable to a new primitive or object.
3. Changing a property of an object referenced by a variable does change the underlying object.
Those are not trivial "just infer it" details. That's highly language specific, and absolutely unrelated to the skills the test claims to be evaluating.
Not a big fan. Feels really weird.
Possibly, the "Is Python call by reference or call by value" question could be rewritten in a language independent form by providing correct syntax Python, the correct python output, and asking verbally "Given either this evidence OR your Python coding experience, is Python call by reference or call by value?"
I've never used Python. I breezed thru the theory and regex questions, presumably I could be a halfway decent Python programmer in a week or two, it looks reasonably non-tricky. Thats another issue, some jobs merely require syntactically correct code, others require good algos, and its a lot easier on the job to learn syntax than to learn algos.
I was frustrated that language features felt trickier than actual coding knowledge in the early questions, but given that it's nothing with actual stakes there's obviously no harm in it.
In one case, I apparently think that Python got it wrong. :-)
Asking the user to choose between 'queue.extend(node)' and 'queue.extend([node])' is purely a Python syntax question; it has nothing to do with programming per se.
The correct answer is node.children, which isn't syntax-specific, it's about the pseudocode of whether you want to visit the node, or the node's children.
And then, after 20 background questions, you could know with high certainty what style of pseudo code (or even language!) a person prefers.
Yeah, I think this is a great idea.
Breakdown:
findMax: language agnostic - should be easy for any programmer
BFS: mostly language agnostic - requires knowing about the .extend method, but the meaning of it can be deduced from context (I did)
modify: requires knowing how variables work in python (storing references to objects), this is the same as Javascript, Ruby, Java, and other. If you only used languages with a different model like Haskell or C, missing this is totally excusable
matrix: same as modify, just a little more complex
factory: requires the variable knowledge + knowledge of closures
int_to_base: language agnostic - only requires knowing recursion
merge: language agnostic - just requires thinking through how merging works
decode-utf8: pretty much just a python thing, but it shouldn't be too hard to guess well if you know about utf-8 and notice the name "bytearray"
As a person who has strong JS/Lua knowledge, I didn't recognise the language as Python, but managed to get them right. I don't think my past experiences of C++, Java, C# would have been at all useful. I've also had a look at languages like Clojure, Elixir, Swift and Rust in my own time, and again that's not useful for this quiz.
It's a fun quiz, but maybe some of the assertions they make ("Only 3% of programmers can get all the way through") are not very fair, given it's not a true assessment.
"There should be a warning label on this thing!!!"
[Update: this is now fixed in the quiz.]
I got that one wrong as well. The question should have been "which regular expression FULLY MATCHES X and not Y"
In [3]: re.search("b[l].*e", "blabber")
Out[3]: <_sre.SRE_Match at 0x7f2db79ed030>
"Matches" means "matches". If they wanted "fully matches", they should have specified "^$". That's why anchors exist.
Let me know what you think!
But the quiz specifically mentions on multiple answers that "In Python, unlike language X, Y, Z" OR "In Python, like [similar language] A, B, C"...I mean this says nothing about my programming ability, this says whether I know the quirks of the language in the same way that I can tell you all the quirks of JavaScript but not in Python. This to me is not a programming quiz, but a Python quiz designed to determine how much someone knows about what can go wrong in Python.
And then with timing attacks - I mean SQL Injection is a fair web security question to ask someone, but the timing is like, very fringe knowledge. Most devs let their framework handle all of those kinds of things. Not sure why I would need to know this unless I was specifically in the sec world.
The last 3 questions were actually general CS because they went through search trees and shortest paths algos, which are language-agnostic.
Like, whatever language you're using, you need to push the children of the current node on to the queue. Only one answer looks like it could reasonably do that.
[1] http://robertheaton.com/2014/02/09/pythons-pass-by-object-re...
[2] http://foobarnbaz.com/2012/07/08/understanding-python-variab...
[3] https://jeffknupp.com/blog/2012/11/13/is-python-callbyvalue-...
Anyway, if you want to bias it into Python, go for it. It's a fun quiz.
Q3: This requires knowledge around the semantics of argument passing, which vary from language to language.
Q4: this again requires some understanding of how values are stored. Some languages will copy, while others will use a reference to the originally inserted value.
Q5: python closure syntax. python scoping rules.
Q8: unless you know what "bytearray.decode" does, the best you can do is make an educated guess from the context.
I think. Not a language lawyer.
I've never used Python.
Not all languages manipulate arrays in the same way re ref/value.
Not all languages have the concept of range() - you could have used a simple array to be more language agnostic.
(I'm sure I could have found more, but I'm Python isn't a language I spend much time in)
https://www.pastery.net/mbeghh/
(it'll print 3)
def do_stuff(mylist=[]):
mylist.append("thing")
Which will lead to the list containing N items after N invocations (i.e. the second function call won't start with an empty list).I'd suggest fine-tuning the question about hashes. My first impression from reading the code, specifically the name user_submitted_hash, was that we were looking at some sort of client-server system where the hash was being calculated remotely and then submitted instead of the original credentials, and that this was a question about not trusting the client. Even without that, in a client-server system the attack you give as the mostly likely wouldn't make much sense given randomness in network latency, so the misunderstanding about the context still breaks the question. Maybe a little more context about how this hypothetical function would be used would help here?
In terms of the presentation here, if you want to show the answers immediately for each question, you might also like to provide some sort of confirmation button. It's frustratingly easy to hit the answer next to the one you intended, particularly on mobile devices. If you're also keeping statistics based on earlier attempts by other people, this is probably distorting your numbers as well.
Good point about the accidental answers. I'll look at that.
The trouble with hypothetical security questions is that it's so difficult to conceive a scenario where you have a deliberate vulnerability that you want someone to see, yet no other implausible aspects that will throw off anyone capable of seeing it. I am reminded of a murder mystery party I once went to with a group of mathematicians, programmers, and other logical people. When we got to the end of the evening and the true murderer was revealed, I think the majority of the participants had long ago ruled out that suspect on the basis of one of several subtle deductions from the clues provided, none of which had apparently been intended or considered by the authors of the scenario. Instead we were supposed to have ignored all the minor inconsistencies in clues and ambiguities in phrasing, and just gone for the person with the flashing neon sign over their head in the first place...
EDIT: I see. The confusion is over partial match vs whole match. I thought whole matches were standard when talking about regular expression in the abstract, but looks like I was wrong. Just changed the problem to include the anchors. Thanks for pointing this out.
In [2]: re.search("b[l].e", "babel")
In [3]: re.search("b[l].e", "blabber") Out[3]: <_sre.SRE_Match at 0x7f2db79ed030>
It looks like they meant "match" as in "re.match", i.e. "^b[l].*e$", which is not the usual definition of the word.
It is not possible to really determine the ability of a programmer in an interview -- the scope is too large. It takes time and effort to understand how well a person will perform. In an interview we try to find indicators of how well a person will perform. So, a quiz that tries to unearth those indicators is interesting.
Your quiz makes me feel that technical details are foremost in your mind when you asses performance. Will the candidate make technical mistakes that you have seen many times before? Similarly, there appears to be considerable bias evident in your selection of questions. All of these questions asses whether or not a candidate deeply understands the functioning of the code snippet, or whether they understand it shallowly. For the candidate who admits a shallow understanding, their only recourse is to guess (and potentially fail).
From that I infer that your cultural makeup is one where you have a bar that you expect all candidates to surpass. This bar is single dimensional, though, and especially your responses to the complaints imply a lack of realisation that you are narrowly optimising for a single useful ability.
Finally, the quiz is set up in a "run the guantlet" fashion. Can you avoid the pitfalls that others have fallen into? This tells me that you fear candidates who do not statically measure up to your bar more than you are excited to find out what a candidate brings to the table.
While you clearly will have other interview techniques for other aspects that you value, this particular quiz would worry me as a candidate. It's essentially the same question 15 times in a different context. When people complain that the quiz is too Python specific, the answer is essentially "But it covers concepts that are similar for many languages and you should be able to figure it out". It's a kind of "Well, I'm sure I could do it pretty easily, so you should be able to too". It makes me worried that there is a lack of empathy on team and that there will be problems if I don't think exactly like the leaders on the team.
On the other hand, this may be fine if that's what you want in your interview process. Personally, I probably would not apply to your company having seen this quiz. This may also be a good thing from your perspective :-). However, if you ever get to a point where, despite having excellent people on staff, you can't seem to get to the next level, I would concentrate on examining potential biases of what is "good" on your team.
Good luck!
This test doesn't cover any of that, makes me worry if they think it does.
it's more :-
do you understand python syntax?
do you understand a few algorithms?
do you understand a few security issues?
not sure how you'd go from this test to working out if a person is a programming generalist. In fact I'd be worried that someone passing this test would be fresh graduated from college where they used python.
1. candidate must discover algorithm to solve unseen problem
2. candidate must code up algorithm discovered in #1
3. candidate's code must work
4. steps 1,2,3 must happen under 1 hour
I think this is a bit too much, and completely misrepresents the current working state of professional programmers.
If I am asked to do #1, I usually do a literature survey - I read papers before rolling my own algo from scratch. 99% of the time, there's a good enough algo already out there.
If #2 - ok.
If #3 - not ok. Typically you need a debugger & 1-2 passes before you get it right.
If #4 - definitely not ok. Step 1 itself can take you forever, and you don't even know if its correct. Then you've got #2,#3...adding time constraint to this mix is crazy.
So yeah, this quiz has two highlights: showing a block of code & asking to fill in the blanks - much better, highly recommended. Also, looking at a block of code & figuring out what it does - definitely part of programmer's everyday work. I hope more companies adapt this technique.
Most interviews are a bit better than that, but I'm always disturbed when people ask for algorithms that aren't either common sense or common knowledge. If it was worthy of publication and isn't relevant to the job, it probably shouldn't be tested on the fly.
This system (and a lot of others) beat the heck out of that.
{"questions":[{"name":"max_function","answerIndex":2,"question":"Fill in the missing line of code:","code": ...
Given that Triplebyte doesn't store answers that way for their job-finding quizzes, the criticism feels a bit hollow.
Congratulations on making this! It's less fun for me than algorithm puzzles, but I can see it working well for hiring purposes. I'd love to see some software company use it and report the results.
I especially enjoyed the post-response explanation of the time and memory bounds of iterative deepening.
It would be a shame to miss the opportunity to test one's skills on such a well put together experience.
This doesn't test understanding in any way. How is it useful to determine whether someone can work on the examples you give, let alone the average software engineering job?
The answers to the graph problems are indeed fairly straight forward. But asking about why one might use a BST in place of a sorted list prompts interesting discussion. And going into Dijkstra's vs A* and iterative deepening depth first search is (I think) pretty interesting!
And I'd say it's unheard of that you would know the first thing about the general, unit weight, problem, and not be familiar with BFS.
(It seems that tweet and the link were fresh in my memory: I automatically interpreted the question as being about password hashes, although the code actually does not imply that at all. And the linked thread is clear about the difference between password hashes and other hashes, but it seems the 'simple' message was more available to me than the deeper truth)
Question for other HN readers : How much did you score on the quiz? I scored 10/15 and it shows that I'm better than 50% of engineers i.e I'm somewhere right in the middle. Not very encouraging, but if I brushed up on the graph algorithms, I could have done better.
What I do hope to do is expand out of the US, and get around the issue that way.
I appreciated that the Python questions were not especially Python specific: the reference questions would have been exactly the same if translated 1:1 into Java, Javascript or C#, and none of them tried to trick you with subtle syntax, types or parameter order.
Bonus points for not having joke answers. They're never funny.
> first half focuses entirely on weird Python quirks.
Wew.
On the plus side, I still somehow managed to get 9 out of 15 right, which apparently puts me above 50% of all programmers.
The (much saner) reality is that continuation characters are never valid ASCII.
10 I admit I got through elimination: three answers were obviously wrong, one could have gone either way.
Overall, I think this is a good level of knowledge that isn't too nitpicky but has enough meat to really test if someone knows something.
The quiz doesn't seem too hard to port (ha, I've heard "it won't be hard to write" before). I think that a good approach might be to let the user see the code in multiple languages via tabs or an interactive select element, like the MSDN docs do.
This quiz posted here is something we created because some people (like you?) are applying to our process just to answer the questions. So we created this version (which does not require an account creation or ask for an email) and totally gives you a score and shows what we think the answers are.
But then I realised that that's not true. For example, call-by-value and call-by-reference are pretty pervasive across languages: many of those examples would've worked the same in Java, say. It's not familiarity with Python, but rather familiarity with a certain kind of language (which admittedly constitutes the majority of those used in industry ATM) that the test demands, at a time when even Java is getting nice FP-like abstractions and the JavaScript community is cooking up all sorts of ways to bring the benefits of that kind of thinking to their own work (from React/Redux all the way to Ramda and the like).
If you're more used to languages that "get out of the way" by eliding what could very well be termed "implementation details" (e.g. is there any reason[0] to use call-by-reference in the absence of global mutable state given a "sufficiently smart optimizing compiler"?), I'd predict (n = 1) that you'll be more likely to make mistakes.
I would've done far better on this quiz back when I was playing with matplotlib as an eighth- or ninth-grader: apart from the token map implementation, the quiz really favors knowledge of counterintuitive behavior common in "mainstream" imperative languages over an understanding of "composability" that users of modern functional languages are used to. (And no, that doesn't only mean Haskell or "ultra-Haskells" like Idris, but also languages like OCaml, F#, and so on.)
It would be much nicer if the quiz could be less about the candidate coaxing her preferred meaning out of a language implementation and more about testing the meanings a candidate knows how to implement with the help of the language.
[0]: For instance, the standard reaction to things like
sum (map (\x -> x ** 2) (map (\y -> sin (y * pi / 10)) [0..9]))
is that a single for-loop is better than this for "real-world purposes". That is very false: the Haskell vector package is usually capable of efficiently fusing the code above into exactly what one would've written by hand.https://www.schoolofhaskell.com/user/commercial/content/vect...
At the risk of going all peak-HN, these things are more a problem with implicit, nonuniform behavior which well-designed languages solve with abstractions like the Copy trait in Rust or even C++ move semantics.
Would be great if authors translated it to at least a couple of other languages.
Also, remove the "generalist" reference. Generalist those questions aren't.
I am a programmer and I run http://www.coderfit.com, a tiny recruiting agency in Zurich / Switzerland (reach out to me via e-mail address in my HN-handle if you look for a tech job in Zurich). Recruiting is really, really hard and I am happy to see platforms like http://interviewing.io and http://triplebyte popping up that give programmers without classic CS background a chance.