227 points · by ammon · 9y ago · 228 comments
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.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.
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...
- 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.
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 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.
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.
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.
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.
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.
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'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)
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.