Live data from Hacker News

I had to give a wrong answer to get the job (2017)

dewitters.com

361–370 of 409 posts

Re: I had to give a wrong answer to get the job (2017)

#361

Earlier quoted context omitted.

Exactly this. When I interview people, I also consider it a HUGE red flag if I can't get the interviewee to say "I don't know" at some point.

This may be a little naive, but what if your expertise runs out before theirs? It’s not unthinkable that a candidate has more depth in a field than you do. I remember asking a friend once if he could answer any Tolkien question, and he answered that he couldn’t answer everything, but the stuff he couldn’t answer, I didn’t know the right questions for.

This has happened. Then you ask them to explain it more.

If you don’t understand then they likely don’t understand it enough to explain it.

Re: I had to give a wrong answer to get the job (2017)

#362

Earlier quoted context omitted.

Isn't there some confirmation bias (not sure if that's necessarily the correct term here, but you'll get the gist regardless) here in that you're more likely to remember the situations in which you catch up with the person who passed you (i.e. "look at this idiot getting nowhere"), and less likely to remember the situations in which that person makes a light that you don't and you never see them again? Massively depe…

Years ago the did an experiment in Germany (I know, a one time test with 2 cars/drivers is more or less anecdata). The task was to drive from Duesseldorf to Munich. Two identical cars, two very experienced drivers. one was told to go as fast as possible without breaking speed limits on the way (we don't have a general speed limit on the German Autobahn (highway)) tthe oother ro drive at a relaxed 120 km/h were possib…

Counter anecdata. I monitor my heartrate (along with other relevant statistics like speed, distance, elevation, and barometric pressure) while engaged in activities like mountaineering. Even when I'm not physically straining myself but just carefully traversing an exposed face, I don't consider a raised heartrate there 'less healthy' in and of itself because it's a side-effect of the excitement I'm feeling, and that feeling (sometimes not necessarily in the moment, but always afterwards) gives me an overall sense of improved wellbeing. Do I get stressed out sometimes? Sure, it's a dangerous activity. But overcoming that and accomplishing my goal rewards my mental health in a different way. Only half tongue-in-cheek: Maybe the faster driver was simply having more fun?

In this case you're probably right that the faster driver was just more stressed for no real benefit, but an EEG is not always a good proxy for how "healthy" something is (even ignoring obvious cases like physical exertion).

If you have a link to the study I'd love to read more.

EDIT:

One other thing I missed on the first read of your comment was the fact that the driver was instructed to "drive as fast as possible" and then given access to roads with no speed limits. I feel like that would have the potential to exacerbate the 'negative' side of things and that a more reasonable middle-ground could be found both in terms of driver stress and also fuel economy.

Re: I had to give a wrong answer to get the job (2017)

#363
post #360

Earlier quoted context omitted.

Easily! You can just make pop do the opposite of push. For example, if push copies two elements to the bigger array, make pop copy two elements to the smaller array.

I challenge you to try to implement it this way and test that (1) an arbitrary sequence of push/pop is valid and (2) doesn’t use more than linear space.

It's pretty easy to make sure an arbitrary sequence is valid if you make push and pop be almost exact opposites of each other.

Let me walk through a simple version based on the description above, ignoring that it's rather inefficient:

Start with an array of size 64, with 32 elements.

Our first action is either a push or a pop. I'll split those up.

* * * If the first action is a push:

From here, call the existing array Small and make a new 128 element array called Big.

For the first push, store it in Small[32]. Then copy Small[0] and Small[1] to Big[0] and Big[1].

For the second push, store it in Small[33]. Then copy Small[2] and Small[3] to Big[2] and Big[3].

Then for a pop, just remove the element in Small[33].

Then pushing again, store it in Small[33]. Then copy Small[2] and Small[3] to Big[2] and Big[3]. Notice how this is exactly the same as the previous push. And if you undid two pushes, then did two more pushes, both of them would be the same as they were before.

So, analyzing this, once we push once, any arbitrary sequence of pushes and pops is going to do one of the following:

* Pushes is always more than pops, but the difference is always under 32. This bounces around forever, undoing and redoing pushes. This is valid, and always uses the same amount of space for 33-63 elements, so that's clearly linear too.

* Eventually pops catches up to pushes. This means we're back to 32 elements, right where we started. Throw out the 'Big' array too. Going back where we started is valid and uses linear space. If the next action is a push, go to the start of the push instructions. If it's a pop, go to the start of the pop instructions.

* Eventually pushes minus pops reaches 32. So now our Small array is completely full, and our Big array is half full, and they contain exactly the same data. Throw out the Small array. Now we're back where we started, except with twice as many elements in an array twice as big. Use all the same logic as before, but with 2x numbers. This is valid and uses linear space.

* * * If the first action is a pop:

From here, call the existing array Big and make a new 32 element array called Small.

For the first pop, copy Big[0] to Small[0]. Then delete and return Big[31].

For the second pop, copy Big[1] to Small[1]. Then delete and return Big[30].

If we get a push, put it in Big[30].

If there's another pop, copy Big[1] to Small[1]. Then delete and return Big[30]. Notice how this is exactly the same as the previous pop. And if you undid two pops, then did two more pops, both of them would be the same as they were before.

So, analyzing this, once we pop once, any arbitrary sequence of pops and pushes is going to do one of the following:

* Pops are always more than pushes, but the difference is always under 16. This bounces around forever, undoing and redoing pops. This is valid, and always uses the same amount of space for 17-31 elements, so that's clearly linear too.

* Eventually pushes catch up to pops. This means we're back to 32 elements, right where we started. Throw out the 'Small' array too. Going back where we started is valid and uses linear space. If the next action is a push, go to the start of the push instructions. If it's a pop, go to the start of the pop instructions.

* Eventually pops minus pushes reaches 16. So now our Small array is half full, and our Big array is one quarter full, and they contain exactly the same data. Throw out the Big array. Now we're back where we started, except with half as many elements in an array half as big. Use all the same logic as before, but with numbers cut by 2x. This is valid and uses linear space.

There.

Now, there are easy optimizations that could be done on top of that to cut the memory use in half, or combine pushing and popping into the same logic, or all sorts of other improvements.

And you want to have a special case if the size gets too small to stop shrinking.

But that should be a perfectly good basic explanation of an algorithm that's very straightforward and has no wiggle room for anything to go wrong.

Re: I had to give a wrong answer to get the job (2017)

#364

Earlier quoted context omitted.

Games work with time budgets of many milliseconds per frame, relatively long timescales from a cpu pov. It is rare to prefer predictable per iteration latency in loops over higher throughput unless the deferred batch of work is quite big. But of course this can compound in some cases, eg you have thousands of these arrays being extended in lockstep and they all trigger the extra work at the same time...

If the arrays are big enough for growing them to mess up your time budget, then it's quite likely that a linked list would already be failing.

[deleted]

Re: I had to give a wrong answer to get the job (2017)

#365

Earlier quoted context omitted.

Games work with time budgets of many milliseconds per frame, relatively long timescales from a cpu pov. It is rare to prefer predictable per iteration latency in loops over higher throughput unless the deferred batch of work is quite big. But of course this can compound in some cases, eg you have thousands of these arrays being extended in lockstep and they all trigger the extra work at the same time...

If the arrays are big enough for growing them to mess up your time budget, then it's quite likely that a linked list would already be failing.

Yep, and the associated dynamic memory allocation for LL nodes will still have latency spikes from the malloc implementation so its worst case latency is still bad.

Re: I had to give a wrong answer to get the job (2017)

#366
post #261

Earlier quoted context omitted.

Haha amazingly there’s a chance I interviewed you, or you interviewed with my company when we were first rolling this out, or another company was also using the same question. I remember the idea was to make the analog like one of those analogs that didn’t move continuously but ticked at every sixty second interval. So it never needed to be in between minute ticks. Lots of us didn’t fully understand the question when…

For the record. Most analog clocks have smooth motion for minute and hour (for the precision of the gearing). Its the second hand that ticks.

I don't know much about clocks, but the Swiss railway clocks are by some considered a canonical example of an analog clock, and they behave the way GP describes. But all other analog clocks I've ever seen behave the way you describe.

https://en.wikipedia.org/wiki/Swiss_railway_clock

Re: I had to give a wrong answer to get the job (2017)

#368
post #275

Earlier quoted context omitted.

>> In some cases amortized isn't good enough though, and games could certainly be one of them! Real time systems including games have hard limits on how long something can take in the worst case, not the average. In games this manifests as: All the stuff has to be done in 16ms to render a frame on time, if we're late the user will perceive a glitch. The consequences can be worse in control systems in any number of re…

So it would be fine if they had said, "okay, for this problem let's add the requirement that every add must be fast, because it's within a frame rendering loop", but (from OP's description) they didn't even seem to understand that's a separate desideratum, or that it doesn't mean the amortized time is bad.

It's probably implicit, it's a gaming company, however it might be fair to say the interviewers didn't appreciate the possibilities outside of gaming and unconsciously assumed this context was understood.

Re: I had to give a wrong answer to get the job (2017)

#369

Earlier quoted context omitted.

am I the only one concerned that this would even be a point of contention? This seems too trivial for anyone doing hiring or being hired to be hung up on.

I mean, I'm guessing this is the main reason that they passed on me, but I'll never know for sure. Maybe they didn't like my personality. Maybe it was some other question I thought I did well on but didn't even realize I got wrong. Maybe a combination of things. For what it's worth, I didn't get a very good vibe from them. The impression I got was that their culture was more aggressive and competitive than I like. (M…

>I'm not really what you'd call a brogrammer.

I'd say you dodged a bullet, but it's more like you dodged a ball.

https://www.youtube.com/watch?v=W-XbDZUnUmw&ab_channel=Movie...

Re: I had to give a wrong answer to get the job (2017)

#370

Earlier quoted context omitted.

Years ago the did an experiment in Germany (I know, a one time test with 2 cars/drivers is more or less anecdata). The task was to drive from Duesseldorf to Munich. Two identical cars, two very experienced drivers. one was told to go as fast as possible without breaking speed limits on the way (we don't have a general speed limit on the German Autobahn (highway)) tthe oother ro drive at a relaxed 120 km/h were possib…

Counter anecdata. I monitor my heartrate (along with other relevant statistics like speed, distance, elevation, and barometric pressure) while engaged in activities like mountaineering. Even when I'm not physically straining myself but just carefully traversing an exposed face, I don't consider a raised heartrate there 'less healthy' in and of itself because it's a side-effect of the excitement I'm feeling, and that…

Along those lines there's a notable pop-sci book by Robert Sapolsky, "Why Zebra's don't get ulcers" (https://www.amazon.com/Why-Zebras-Dont-Ulcers-Third/dp/08050...).

Basically this guy made his scientific career by doing epic experiments where he observed communities of baboons during various social interactions, blow-gunned individual baboons with tranquilizers, then very quickly, took samples of their blood to analyze glucocorticoids (these are stress-response hormones and have a half-life measured in minutes).

Anyway, crudely stated, the major finding is that animals have intense episodic stress throughout their lives but never suffer health consequences from that stress because it's occasional. Humans, on the other hand, can get the same levels of "fight-or-flight" stress but at long-lived, daily intervals. Excessive glucocorticoids, over a long term, can interfere with the normal functioning of the body and precipitate a wide variety of health problems including heart-disease (and ulcers, as the title suggests).

In the case of driving, an aggressive lane-changing drive in a fast car might be exhilarating under certain conditions, but it's a different story for a daily commute. It's no accident that the advice given to people that experience aggressive drivers on the road is often along the lines of "Let him go, don't become a part of his bad day." Aggressive driving is a self-reinforcing bad habit that becomes part of people's identity in many cases. Personally, I don't care about the health of aggressive drivers, but I do care about their propensity to cause accidents and hurt innocent people.

Post reply on HN