{"id":628,"date":"2015-10-29T18:24:27","date_gmt":"2015-10-30T01:24:27","guid":{"rendered":"http:\/\/kagan.mactane.org\/blog\/?p=628"},"modified":"2015-10-29T16:37:23","modified_gmt":"2015-10-29T23:37:23","slug":"whats-wrong-with-the-minimal-weighings-puzzle-for-front-end-interviews","status":"publish","type":"post","link":"https:\/\/kagan.mactane.org\/blog\/2015\/10\/29\/whats-wrong-with-the-minimal-weighings-puzzle-for-front-end-interviews\/","title":{"rendered":"What&#8217;s Wrong With the &#8220;Minimal Weighings&#8221; Puzzle for Front-End Interviews"},"content":{"rendered":"<p>A while back, I came across <a href=\"http:\/\/css-tricks.com\/interviewing-front-end-engineer-san-francisco\/\">a post by Philip Walton<\/a>, who points out that most front-end interview questions aren&#8217;t well suited for their basic task of&#8230; well, testing a candidate&#8217;s front-end development knowledge. At least, the sorts of things he ran into were mostly &#8220;logical puzzles, generic coding challenges, and algorithm design problems&#8221;, as opposed to the kinds of questions that might test a candidate&#8217;s <em>actual knowledge of <strong>front-end<\/strong>&nbsp;coding<\/em>.<\/p>\n<p>I&#8217;m happy at my current job, have been so for five years now, and don&#8217;t expect to be on the job market again any time soon. But if I were out there, I&#8217;m sure I&#8217;d run into more of those puzzles and brain-teasers. Like the one that&nbsp;runs:<\/p>\n<p>You have <span class=\"mathVar\">N<\/span> coins. They all weigh the same amount, except for one that is counterfeit. It might weigh slightly more, or slightly less, than the other coins. You have a balance, which can compare the weights of any two objects. How can you determine which is the counterfeit coin, using only <span class=\"mathVar\">X<\/span> weighings?<\/p>\n<p>Some time, I want to respond to that question about determining which of a set of coins is the &#8220;wrong&#8221; or &#8220;deviant&#8221; weight with a minimal number of weighings like&nbsp;so:<\/p>\n<p class=\"hanging\"><strong>Me:<\/strong> Why only three weighings? Does it cost us money to use this scale or something?\n<\/p>\n<p class=\"hanging\"><strong>Interviewer:<\/strong> Well, maybe not <em>money<\/em>, but it does take some time. So you could think of it as representing a way of minimizing how many CPU cycles the operation takes.\n<\/p>\n<p class=\"hanging\"><strong>Me:<\/strong> Fair enough. But come on, are CPU cycles really that scarce? This might be a reasonable question to ask an Assembly or even C programmer, or if we were going to be working in an embedded system with limited resources. But seriously: You&#8217;re interviewing me for a <em>client-side web development<\/em> position. Any environment my code runs in has more than enough CPU.\n<\/p>\n<p class=\"hanging\"><strong>Interviewer:<\/strong> Some people&#8217;s phones are kind of underpowered&#8230;\n<\/p>\n<p class=\"hanging\"><strong>Me:<\/strong> No. Look, any environment my code is running in has a <em>full, complete GUI<\/em> running on it. That thing is using up <em>so<\/em> many more CPU cycles than a few extra comparisons, it&#8217;s not even funny. Sure, I should know about algorithmic complexity, and I should prefer constant-time algorithms, then <span class=\"mathVar\">O(log&nbsp;n)<\/span> ones, then <span class=\"mathVar\">O(n)<\/span> ones, before getting into <span class=\"mathVar\">O(n&nbsp;log&nbsp;n)<\/span> or <span class=\"mathVar\">O(n<sup>2<\/sup>)<\/span> ones. But shaving a few comparisons off one loop? That&#8217;s ridiculous. That&#8217;s <em>optimizing for the wrong thing<\/em>, namely, CPU cycles over programmer time and effort and brain-space.<\/p>\n<p>If I ever need to know that particular algorithm, I can look it up. Which is why I&#8217;ve never bothered to learn it. But seriously, if <em>I<\/em> ever need to know that algorithm? Then <strong>we are doing something completely wrong<\/strong>, and probably at an architectural&nbsp;level.\n<\/p>\n<p>This will probably not get me the job. That&#8217;s completely okay. That job <em>is broken<\/em>, because its interview process is broken&nbsp;&mdash; it&#8217;s selecting for the wrong thing(s). Which means <em>everyone else<\/em> at that job has <em>already been selected on the <strong>wrong&nbsp;criteria<\/strong>.<\/em><\/p>\n<p>I can&#8217;t fix that. The best I can do is keep my&nbsp;distance.<\/p>\n<p>But <strong>if you&#8217;re using questions like that<\/strong> as part of your hiring process&#8230; think again. What are you selecting for? What do your coders <em>actually<\/em> need to know, and what are things that they will never, in a million years, need to use on the&nbsp;job?<\/p>\n<p>And which of those things are your interview questions&nbsp;testing?<\/p>\n<p>(By the way, if you want some decent front-end developer interview questions, you can find a bunch at <a href=\"https:\/\/github.com\/h5bp\/Front-end-Developer-Interview-Questions\">https:\/\/github.com\/h5bp\/Front-end-Developer-Interview-Questions<\/a>.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A while back, I came across a post by Philip Walton, who points out that most front-end interview questions aren&#8217;t well suited for their basic task of&#8230; well, testing a candidate&#8217;s front-end development knowledge. At least, the sorts of things he ran into were mostly &#8220;logical puzzles, generic coding challenges, and algorithm design problems&#8221;, as [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[108,103,29,30],"_links":{"self":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/628"}],"collection":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/comments?post=628"}],"version-history":[{"count":4,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions"}],"predecessor-version":[{"id":632,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/628\/revisions\/632"}],"wp:attachment":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/media?parent=628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/categories?post=628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/tags?post=628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}