by geuis · 17y ago · 0 comments
My answer in 15 seconds: var sqr = function(e){ return Math.sqrt(e); }
Easy enough. But no, he wanted a function that demonstrated an algorithm to find the square root. Ok... I said. I spent a minute trying to salvage some odd details from high-school algebra and basically came up blank. I was thinking, well this isn't going to look good on me. I readily admit to him that my knowledge of figuring out square roots by hand is a rusty, having been out of high school for 12 years(even though in retrospect, this was something we were never really even taught anyway). But surely this guy, who is screening me for my ability to do front-end coding, will move on and start asking me some hard problems about javascript, css, cross browser problems, etc. No.
We spend the next 6-8 minutes with him circling back on his square root problem. I tried a couple more times to answer this question that is completely unrelated to the job I'm interviewing for. Finally, I get so fed up with this moron that my internal ticker clicks over and I realize, "Even if I get this job, I'm going to be dealing with these kinds of nazel-gazing engineers every single day. Not an environment I want to be in." I thanked him for his time, and he acts surprised and says "Are you sure? After everything it took to get to talk to me?". Yes, I say. I'm quite sure. >Click.<
I realized a long time ago what kind of people these are. When I was growing up, the garbage truck would come by on Tuesdays and Thursdays. When we first moved to the neighborhood, we would put our garbage out by the mailbox and some days it would be picked up and sometimes not. We would complain and nothing would change.
After a few weeks, I was standing out front when they came by. I noticed that everyone had their trash bags on the right side of their mailboxes. That morning, I had done that as well. But some new neighbors down the street had put theirs out on the left side of their mailbox. The truck comes by, grubby guys grabbing/throwing, grabbing throwing. All the garbage gone, except for the neighbors. The next time, I purposely left ours on the left side. Didn't get picked up that day.
So that was the day that I realized these guys had their Line In The Sand. It was Their Way or the Highway. They had a really crappy job. Probably crappy lives at home because they're garbage men. This was Florida, not NYC. There's no glamor or high-pay there. This was the one place where they were the kings, the arbiters of Pickup Or Not. This was the one point of control over their lives they could influence, and they grabbed onto with both hands and some toes.
So this little middling engineer at Facebook had his Line too, in the form of a square root function that Had To Be ANSWERED! "You shall not cross!" He exclaims internally. I'm positive he was quite satisfied with himself after I hung up. Some self congratulation at keeping another peasant out of the castle halls. Kind of like the junk yard dog on a chain behind the fence. Smug in barking and keeping away the kids, but still chained to his dog house.
I was once part of a college team where nothing ever got done because people couldn't agree on using git vs. svn. Bravo.
Age may play a role. These sorts of questions are the geek equivalent having the shiniest back in the forest. But given that tech companies almost universally strive to create a culture of "we're special," it seems inevitable that you're going to get arbitrary rites of initiation into the various geek tribes.
I wonder if FB has formal standards for its interview process, or if they just grab someone and say "Hey, go interview this guy."
I'd immediately tell you to use Newton's method, what Newton's method is and (if you didn't have a college degree) what derivative is.
Then we'd go through the exercise of doing it for square root and then I'd see if you could the fact that Javascript has support for first-order functions to implement it similarly to how it's done in SICP:
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html...
(I really do wonder if this is what the Facebook interviewer wanted to hear, but I am doubting it.)
How does front-end design work significantly overlap with this? I would wager that one could quiz the best CSS/Javascript gurus in the world and not a single one would know, nor care.
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html...
you would think it would suffice to just tell him, yeah, i am aware that the newton-raphson method exists, and what it is supposed to do.
But personally, yeah, I'd use Math.sqrt.
Everyone who says "this question is completely irrelevant" isn't completely right. This question would be completely irrelevant if they were exclusively looking for a "fancy" square root finding technique. However, binary search is a pretty basic algorithm - the trick here is to recognize that such a basic algorithm can be applied to a seemingly unrelated problem. If Facebook is testing to see if people can connect different parts of their knowledge (square root function is strictly increasing, something that everyone knows to be true at least intuitively, combined with the fact that binary search can then be used in such a situation), then it's a reasonable question to ask. Maybe not for a front-end developer though.