|
There is an old trick from days when memory sizes were counted in bytes. (No I did not figure it out and had to be taught it.)
Use three exclusive or operations. This will avoid the overflow issue of using add and subtract.
For example:
a = 15
b = 5
a = a^b
b = b^a
a = a^b
|
|
|
|
|
I've always liked this trick since I first saw it in an assembler manual for PLAN (there must be other OPers who remember PLAN). The only problem with it is that it only works with integers.
|
|
|
|
|
I remember that from my C days. If someone asked me that in JavaScript though I'd have to take a step back end think about.... a lot. I miss a good XOR at times.
Jeremy Falcon
|
|
|
|
|
|
Jeremy Falcon wrote: Does anyone else think coding interviews are fundamentally broken? Perhaps, but of the ones I've partaken in, it may also be me. With three decades under my belt, there's not much I can't do, yet I feel totally inept when asked "How would you solve" questions.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I think after years you become so focused on real problems and real solutions, that such out-of-the-world questions are irritating you so much you not even feel to do a real effort...
You take it as an insult to your developer intelligence
"The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012
|
|
|
|
|
I must agree with this sentiment.
Jeremy Falcon
|
|
|
|
|
Here's the problem:
Most people involved in hiring, (HR and managers), wouldn't recognise talent if the candidate had it tattooed across their forehead. So they resort to 'mechanical' methods of selection. If anywhere needs the help of AI, it's recruitment - because the real stuff isn't in abundance!
|
|
|
|
|
This isn't an anti-management or anti-interviewer thing. I've been in management. I've hired people. More developers need to understand the other side of life before casting judgment.
Anyway, my recruiter was awesome. The interviewer was great too. Super friendly and knowledgeable. It was a great experience, just broken in the way we go about it.
Jeremy Falcon
|
|
|
|
|
Btw, I do agree that a lot of recruiters and HR only go for the buzzword bingo game... but in this instance the recruiter was fantastic.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: Anyone else agree this is fundamentally broken?
Yes. For experienced folks, just a problem solving should not be the one to decide. It could also be an off day not just unable to answer exactly as the interviewer is expecting.
|
|
|
|
|
To be fair, putting arbitrary things at the bottom of the pile is a pretty important task for companies these days so it's no wonder they want to know you're good at it.
|
|
|
|
|
True... I could see that for sorting say notifications on the frontend, but 9 times out of 10 you'd use a method like Array.protoype.sort() rather than roll your own. Point being, for most LOB applications... we don't have to re-invent the wheel.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: we don't have to re-invent the wheel.
That is probably the correct answer. Any good programmer will reuse (or, at least, get good ideas from) code that has been proven reliable rather than creating something new that may contain bugs.
|
|
|
|
|
jsc42 wrote: rather than creating something new that may contain bugs. Exactly
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: Anyone else agree this is fundamentally broken?
Yes. The answer that I gave some folks a couple years ago was "Please don't ask me questions I can google the answer for."
There was a few seconds of silence.
The question they asked me was something along the lines of "what's an abstract class?" Seriously? I've been programming for 40+ years and you ask me that???
Marc
|
|
|
|
|
Marc Clifton wrote: The question they asked me was something along the lines of "what's an abstract class?" Seriously? I've been programming for 40+ years and you ask me that???
Ha ha ha ha ha ha. I laugh because I know developers who have asked a question like that way more than once. Interviewing is a bit of a skill unfortunately. It's not something that just naturally comes to people simply because they learn to program. Granted, it's important you are technical in one IMO, but you gotta learn the soft skills too.
Jeremy Falcon
|
|
|
|
|
Quote: Please don't ask me questions I can google the answer for great line idd ...
|
|
|
|
|
Marc Clifton wrote: "what's an abstract class?"
A lesson where you learn to paint like Mondrian?
|
|
|
|
|
Suddenly I think about "ICT-competences modelling" as a few years ago I participated in a research project on higher ICT education. Indeed I think that most HR "still" do not pay attention to relevant aspects of a "programmer"-profile such as communication capabilities, team skills, problem solving, organizing the work, etc ...
modified 23-Sep-20 11:19am.
|
|
|
|
|
It is annoying when faced with something like this, but it is surprisingly common. In my opinion a programming test should be short, simple and should only be possible to be failed by someone who can not program - ideally you should be able to use it as a springboard for discussing programming techniques.
A lot of people are not good at on the spot tests like this, so this type of interview gets a lot of false negatives.
I guess Acelook can pass over good candidates, because they have a lot of candidates to choose from. Perhaps they use custom algorithms and need every programmer to be able to create them.
One slight point though - your single loop solution will typically be slightly less efficient then the two loop solution, although it does seem clearer what your solution is doing.
Addendum: So when does OG start at Acelook?
|
|
|
|
|
Fueled By Caffeine wrote: A lot of people are not good at on the spot tests like this, so this type of interview gets a lot of false negatives.
Yeah that's exactly right. It takes time to analyze a problem you haven't run across before. When the interview is cut short... time is not on your side. It's so much easier to spend time working on it when nobody is watching. It's almost to be a developer you have to study algorithms you'll never use and study what you'll actually be doing. Twice the effort for half the gain.
Fueled By Caffeine wrote: One slight point though - your single loop solution will typically be slightly less efficient then the two loop solution, although it does seem clearer what your solution is doing.
Oh I agree. The further up the loop you go in the second solution the quicker it becomes, but still... hard to work against the clock like that for something new. Such is life I guess. Bubble type sorts are slow, but at least they are tried and true... which is why I went that route for the second solution. Given enough time... I'd like to think I could've done better. Guess, I'll have to brush up on stuff I'll never use once I get the job.
Fueled By Caffeine wrote: Addendum: So when does OG start at Acelook?
Dunno... hopefully he'll get me in the door too.
Jeremy Falcon
|
|
|
|
|
Jeremy Falcon wrote: ...the quicker it becomes, but still... hard to work against the clock like that for something new... Grumpy Old Man mode (IE, Wise and Omniscient Programmer Mode): "Is this going to be a mission critical component of the software that will handle hundreds of millions to billions of values in an array, day in and day out? If not, buzz of - ANY solution I come up with for a twenty element array will be finished so shortly after the 'Enter' key is pressed with modern hardware that it doesn't matter. All that matters is getting on to the next thing.
But then again, that probably isn't the right way to butter up a prospective job, although a good interviewer should recognize the truth to your statement and be much more inclined to hire you.
|
|
|
|
|
|
I've had to hire for several firms. I don't think probing technical questions are even the best way to find good developers.
Testing how people think is I think the best approach, but it's not always easy to come up with good questions for this.
If I had my way, I'd be able to give each candidate a simple set of functional requirements and have them produce a small application (like notepad)
then I'd look at the code.
However, in practice, I've never had the opportunity to look at someone's coding style on demand like that. Whiteboarding is one thing, but it only gets you so far.
When I do ask technical questions they are usually things like what is the practical difference between a linked list and a vector just to make sure they aren't totally wasting everyone's time but I can get that out of the way on the phone in a lot of cases.
What I really look for though - and this puts a candidate on a shortlist for me is - do they love to code? Is it a passion? If the answer is yes, I can assume a fair number of important things about them, like that they will throw themselves at a new coding challenge rather than avoid them. The green ones are not always the best project managers, but they typically make solid coders who learn fast. Talent comes from passion, IMO. The nice thing about this, is you can tell. Do their eyes light up when they talk about code, or is it just a job to them? You can almost always tell when someone is really passionate about what they do.
All that being said, I guess it should be obvious that I profoundly disagree with the techniques of interviewers you had. The questions they asked didn't find talent, and didn't really rate your ability. It seems like a poorly executed question attempting to get at the way that you think. And apparently it was complicated enough to trip up the interviewer themselves, which led them to passing over you. It sounds like they think an interview is an attempt to outsmart others and they succeeded in only outsmarting themselves.
Even when I'm in your shoes I'm always the interviewer. The question in my mind when I approach a company is do *I* want to work for you? That has always served me well.
You know what I think? I think you don't want to work for people like that anyway.
I don't think they know how to find talent, so they probably don't appreciate the talent they have. If they did, one of them would have been interviewing you and what happened to you wouldn't have happened. So maybe they can't retain good people. It happens to a lot of large companies. Google and Microsoft work very hard knowing that. Maybe try them out.
Sorry for the long winded reply. I have a lot of feelings about the way the field hires.
Real programmers use butterflies
|
|
|
|