|
feedmegin posted:Why modulus? In C its just for(count=1; count<1000;count +=2) { sum += count; } or similar... When i checked if the input range included even numbers
|
# ? Jun 12, 2016 02:58 |
|
|
# ? May 23, 2024 17:12 |
|
Space Whale posted:When i checked if the input range included even numbers So if the question posed to you was exactly what you said - "How would you compute the sum of all odd numbers from 1 to 1000?" - then it's possible they thought you went overboard by doing all this: quote:logic to handle inputs, bumps up the start of the sequence if it's even and bumps down the end if it's even, make sure the start is less than the end They didn't ask for a method which can compute the sum of all odd numbers over non-continuous unordered sequences. Quite likely they tossed you an introductory softball question and when you broke out a parametric equation solver to compute the angle of the pitch they thought "Why didn't they just hit the stupid ball?" At my last job as a hiring manager we would give potential applicants a fairly basic test that involved making an object with some polymorphic properties and a linked list in which to hold them. It can be argued all day over whether this was a Good Test or not but I remember very clearly one applicant who did it in Java and wrote ObjectFactories for every single thing. The whole test ended up something like fifteen printed pages. As a result we went into the interview having serious concerns over whether they could actually do coding tasks without going to pieces overthinking the situation and not ever completing anything that wasn't perfectly [according to them] architected. edit: It's also possible they were looking to trap you with unstated assumptions! The right thing to do is to ask "Is the input ordered? Is it all integers between 1 and 1000?" and so on. Then apply solutions as you see fit.
|
# ? Jun 13, 2016 13:17 |
|
Also, and this is a small thing, but I assume C# has the usual logic operators, in which case '(foo & 0x1) == 1' is probably better than foo % 2. I mean, a decent compiler should optimise the latter to the former anyway, but at the hardware level modulus is either a lot slower than an and (on x86 for instance) or not even in the ISA (for ARM).
|
# ? Jun 13, 2016 15:23 |
|
feedmegin posted:Also, and this is a small thing, but I assume C# has the usual logic operators, in which case '(foo & 0x1) == 1' is probably better than foo % 2. I mean, a decent compiler should optimise the latter to the former anyway, but at the hardware level modulus is either a lot slower than an and (on x86 for instance) or not even in the ISA (for ARM). Oh god no. Write intent first, savagely optimize if you can prove that it helps and optimizer won't do it for you.
|
# ? Jun 13, 2016 20:06 |
|
feedmegin posted:Also, and this is a small thing, but I assume C# has the usual logic operators, in which case '(foo & 0x1) == 1' is probably better than foo % 2. I mean, a decent compiler should optimise the latter to the former anyway, but at the hardware level modulus is either a lot slower than an and (on x86 for instance) or not even in the ISA (for ARM). It's already been pointed out that summing an arithmetic sequence has a closed-form solution, so if you cared at all about efficiency you'd use that, not wring your hands over whether it's better to use % or twiddle bits.
|
# ? Jun 13, 2016 20:17 |
|
I did say it was a small thing! Maybe it's because I tend to do low-level stuff a lot but the bit-twiddling approach looks better to me. I certainly wouldn't hold it against a candidate if they did the modulus version.
|
# ? Jun 13, 2016 20:22 |
|
I'd penalize any solution that didn't use the fact that the sum of the first n odd numbers is n^2. You can easily pick up on the pattern by summing the first four odd numbers, so it's not like it's some obscure fact you need to memorize, and any developer should check for such obvious patterns before doing things in the most obvious possible way. But I wouldn't care whether someone used modulus or bit twiddling, they are both equally suboptimal.
|
# ? Jun 13, 2016 20:26 |
|
PT6A posted:I'd penalize any solution that didn't use the fact that the sum of the first n odd numbers is n^2. You can easily pick up on the pattern by summing the first four odd numbers, so it's not like it's some obscure fact you need to memorize, and any developer should check for such obvious patterns before doing things in the most obvious possible way. I, like, have a history of being unnecessarily aware of stupid math tricks, and even I never noticed this rule until I was explicitly told about it, in or after college. I mean seriously if you know your arithmetic sequences you'll get the closed form solution and simplify it to n^2 anyway, but... it's not something where an educated person would even bother looking for a pattern! You already know the pattern will be quadratic growth, and it coming out to n^2 exactly is unfathomable luck. So the thought process is more like, okay, to sum the series I need to multiply how many elements there are times their average value, and... that's (n/2)(n/2), thus 1M/4, thus 250K. Or it's like, I know sum{k=1 to n}(k) = n(n+1)/2, therefore, I've got sum{k=1 to n}(a + bk) = an + sum{k=1 to n}(bk) = an + b*sum{k=1 to n}(k) = an + b*(n(n+1)/2). Which thereby simplifies to n^2 (when a=-1, b=2).
|
# ? Jun 13, 2016 20:52 |
|
Instead of deriving the closed-form solution, I just calculated the first four numbers in the sequence and noted that they were all perfect squares. You don't need to be some insane mathematician to do that, frankly.
|
# ? Jun 13, 2016 21:54 |
|
PT6A posted:Instead of deriving the closed-form solution, I just calculated the first four numbers in the sequence and noted that they were all perfect squares. You don't need to be some insane mathematician to do that, frankly. A solution assuming a very small finite set matches a much wider pattern without a proof is itself a horror.
|
# ? Jun 13, 2016 22:06 |
|
leper khan posted:A solution assuming a very small finite set matches a much wider pattern without a proof is itself a horror. An inductive proof is trivial to confirm your finding, though I would agree you'd want to include that part in an interview. I think it's a poor interview question precisely because there's a fairly obvious closed-form solution. If you want to see if the candidate knows about the modulus operator, there are better questions to ask, so if I asked that question, it would be in order to see how the candidate's mind works, and what I'd want to see is that they consider solutions other than the trivial iterative solution.
|
# ? Jun 13, 2016 22:12 |
|
If I was the interviewee looking at that exact problem, I would point out that a closed-form solution exists but ask the interviewer if they were asking in order to see whether I could provide a solution involving iteration, and if they said yes then I would offer to give a solution in that form. If I was the interviewer hoping to test whether the interviewee could come up with a solution involving iteration to a problem, I hope I'd manage to find something to ask that didn't have quite such a straightforward closed-form solution, but if one candidate spotted one I wouldn't regard them as being above the other candidates on that basis, unless maybe it was a position where strong mathematical aptitude would be advantageous.
|
# ? Jun 13, 2016 22:18 |
|
If you want someone to write code then don't ask them to solve a math problem. My answer to the question as stated would be "with a calculator" or "with pencil and paper" because it's an easy algebra homework problem.
|
# ? Jun 13, 2016 22:50 |
|
Once an interviewer with a Java background asked me "I don't code in Objective-C, but how do you achieve multiple inheritance in that language?" I kind of just freaked out and assumed he knew what he was talking about, and that multiple inheritance was a thing in Objective-C. I tried to make up whatever answers I could, and it was a bunch of nonsense and really wrong. I didn't get the job of course. If I was calmer, and thought about it, I would have explained what composition was.
|
# ? Jun 14, 2016 17:20 |
|
csammis posted:So if the question posed to you was exactly what you said - "How would you compute the sum of all odd numbers from 1 to 1000?" - then it's possible they thought you went overboard by doing all this: The fact that you can't actually trust your interviewer and it's basically a guessing game of what they really want is another horror. I mostly did it in csharppad because I'd like to run something, not just throw poo poo into notepad. Why the hell NOT use a REPL?
|
# ? Jun 17, 2016 02:16 |
|
Programming interviews are just insane. I thought for sure I had nailed a fantastic job at one point but got a rejection letter and not a single clue as to why. The job I did get I didn't hear from the place for like two months before being told "hey dude, they're interested!" All they asked me to do in the technical interview was to write a FizzBuzz and do Fibonacci numbers and I started doing it iteratively and was like "you can do this recursively too but recursion I avoid." He only had to prod me a little on the recursion part; then I couldn't say why recursion was kind of bad because I didn't remember. It's the only place that didn't ask for a specific language. Probably 6 weeks later they offered me a job. It's a web dev position even though I told the guy that my web dev skills are currently kind of lovely. Then I negotiated for more than 25% over of their initial offer. Though the thing that baffled me the most was interviews I had where I ended up being asked to write code in very short terms in languages that I made absolutely no indication that I knew. It wasn't on my resume. I never mentioned the languages. I even said "my web dev skills aren't great." Then the interview was like "hey do this thing in PHP in half an hour, go!" with no indicator that I'd be writing PHP. I don't know PHP. At all. Other places would indicate that they were looking for people at every level (often with remote work being OK), didn't care what languages you knew, liked strong math skills, and were more interested in fundamental strengths than specifics. I was a CS major with a math minor with some extra logic thrown in along the way and they wouldn't even call me back. Though I like games and AI the most I just like to code in general and will work on pretty much anything for a paycheck. Technology fascinates me and I mentioned that in interviews when concerns were expressed; they'd say "why don't you go for games programming?" Well that's because the games industry often treats its people badly and non-games stuff pays better. I can fart around with games in my own time as a hobby. Many places went "lol nope, don't want you" anyway. I do not understand the programmer interview process at all. ToxicSlurpee fucked around with this message at 02:46 on Jun 17, 2016 |
# ? Jun 17, 2016 02:42 |
|
I got a job once because I was cool and held up my race wheel/race tire up to the webcam during the video screen. Then, during the in person, I was over optimizing (when asked to optimise) and the following exchange happened: "are strings mutable?" "Hell no" *scribbles stringbuilder on whiteboard* "ok you got it" They also asked if I knew why you would denormalize tables. I had no loving clue and they didn't care they just wondered if anyone knew why the DBA did that sometimes.
|
# ? Jun 17, 2016 02:53 |
Space Whale posted:They also asked if I knew why you would denormalize tables. I had no loving clue and they didn't care they just wondered if anyone knew why the DBA did that sometimes. For some reason, I am very amused by the idea of these people asking job candidates this question, because they are baffled by their DBAs, but too scared to question them. Maybe there was never a job. They just figured they could interview people until someone knew what database denormalization was, but you accidentally wowed them by knowing something about strings.
|
|
# ? Jun 17, 2016 04:59 |
|
ToxicSlurpee posted:Though the thing that baffled me the most was interviews I had where I ended up being asked to write code in very short terms in languages that I made absolutely no indication that I knew. It wasn't on my resume. I never mentioned the languages. I even said "my web dev skills aren't great." Then the interview was like "hey do this thing in PHP in half an hour, go!" with no indicator that I'd be writing PHP. I don't know PHP. At all. They might just want to spring a language on you that you nothing about to see whether you can pick thing up quickly in order to get poo poo done. That's a good skill to have, although of course using a language in anger when you don't know it is a good way to make boneheaded mistakes and write bugs, so it's to be used with appropriate caution. Or they might be incompetent, either/or
|
# ? Jun 17, 2016 10:34 |
|
Space Whale posted:They also asked if I knew why you would denormalize tables. I had no loving clue and they didn't care they just wondered if anyone knew why the DBA did that sometimes. Some devs go crazy with normalization in the same way that some devs go crazy with abstraction and it becomes not only a form of premature optimization, but annoying and a drag on development efforts.
|
# ? Jun 17, 2016 16:05 |
|
Space Whale posted:The fact that you can't actually trust your interviewer and it's basically a guessing game of what they really want is another horror. You should try not to take it too personally and really don't think of it like a "trust betrayed" situation. Half of their entire job at that moment is to determine whether you have flaws that would be a detriment to their goals and that means poking at spots that look weak. "I think my interpretation is correct" is a very common assumption when programmers are given problems and the inability or unwillingness to determine one's own correctness is more often than not a weakness. Always question your assumptions - in an interview situation, that means question the interviewers. Make sure you understand the problem before you break out the REPL or Notepad or even a piece of paper and a pencil. No one cares how fast code can be produced if the code is solving the wrong problem. Producing wrong code costs real money.
|
# ? Jun 17, 2016 17:48 |
|
Hammerite posted:They might just want to spring a language on you that you nothing about to see whether you can pick thing up quickly in order to get poo poo done. That's a good skill to have, although of course using a language in anger when you don't know it is a good way to make boneheaded mistakes and write bugs, so it's to be used with appropriate caution. It would be hard to write anything in PHP if don't even know the syntax at all.
|
# ? Jun 17, 2016 17:54 |
|
When I interviewed for my current job as C# developer the only technical question they asked me was 'do you know any C# ?', and my answer was 'No, I've never written a line of C#, but I have 5 years of professional experience in C++ and a masters degree in computer science, I'm sure it'll be fine'. They we're all 'o sure, don't sweat it', and then we spend a couple of hours talking about their product, development processes, my role in development teams, and my professional attitude. Do people really ask all this FizzBuzz type bullshit on anything other than entry level jobs?
|
# ? Jun 17, 2016 19:01 |
|
You would be shocked how many ostensibly experienced software developers cannot do FizzBuzz in pseudocode. I don't even mean they have a a problem with their implementation. Most of the people I've interviewed don't even know where to begin, which leads me to believe their claimed experience or CS education is simply made up.
|
# ? Jun 17, 2016 19:27 |
|
Then ask them to tell about their previous projects, let them do a mini presentation, explaining the product, the problems, the challenges, the solutions, their role in it. That is way better method to find out of somebody is lying about their experience than having them do a FIzzBuzz. (And it will give you some insight in how they operate in development teams and what they may contribute to a team, which is way more important than pure coding skills anyway)
|
# ? Jun 17, 2016 20:38 |
|
What? FizzBuzz should only take five minutes. It's not an obstacle to any other discussion.
|
# ? Jun 17, 2016 20:54 |
|
Asking people to spend more time lying to you only catches the bad liars. There are a lot of people that can spend a long time talking about what other people on their team did as if it was them without getting tripped up.
|
# ? Jun 17, 2016 21:11 |
|
Confusion posted:Then ask them to tell about their previous projects, let them do a mini presentation, explaining the product, the problems, the challenges, the solutions, their role in it. That is way better method to find out of somebody is lying about their experience than having them do a FizzBuzz. (And it will give you some insight in how they operate in development teams and what they may contribute to a team, which is way more important than pure coding skills anyway) The thing is, though, a lot of people in tech *can* talk proficiently about things. Even *technical* things. But still be incapable of implementing those things reasonably. A developer buddy of mine recently interviewed for a mid-level seat(3-5 years experience) on another team in the company. They asked him why you'd want to use a StringBuilder. He told them when you're doing lots of string concatenation. They told him he was the first candidate they've spoken to that could answer the question correctly This isn't even in the weeds of REALLY complicated stuff, I mean holy poo poo.
|
# ? Jun 17, 2016 21:45 |
|
icecreamcheesesteak posted:It would be hard to write anything in PHP if don't even know the syntax at all. I'm assuming in this context that they'd be allowed access to Google and to ask questions incidental to the problem at hand, like "what's the standard library function for doing xyz in PHP". Not just hacking away blindly in Notepad. Syntax-wise PHP is a semicolons-and-braces language, it's not like it's really out there.
|
# ? Jun 17, 2016 22:45 |
|
Confusion posted:When I interviewed for my current job as C# developer the only technical question they asked me was 'do you know any C# ?', and my answer was 'No, I've never written a line of C#, but I have 5 years of professional experience in C++ and a masters degree in computer science, I'm sure it'll be fine'. They we're all 'o sure, don't sweat it', and then we spend a couple of hours talking about their product, development processes, my role in development teams, and my professional attitude. If you can write C++ you can write C#; if you have provable experience with C++ moving to C# is pretty easy. Going the other way is...a different story. I've heard of people who had provable senior-level experience failing FizzBuzz. How is a mystery to me but apparently (from what I've heard, anyway) it doesn't matter what level you're interviewing at; half of people being interviewed can't write FizzBuzz.
|
# ? Jun 18, 2016 02:01 |
|
ToxicSlurpee posted:If you can write C++ you can write C#; if you have provable experience with C++ moving to C# is pretty easy. The theory I usually hear about senior people with known experience is that they've essentially become managers and haven't written new code for a few years. At some point, I would expect most people who no longer interact with code to lose their abilities, much the same way you forget the specifics of advanced mathematics unless you keep up studies. Not sure why they wouldn't interview for managerial positions if that were the case though.
|
# ? Jun 18, 2016 02:23 |
|
leper khan posted:The theory I usually hear about senior people with known experience is that they've essentially become managers and haven't written new code for a few years. At some point, I would expect most people who no longer interact with code to lose their abilities, much the same way you forget the specifics of advanced mathematics unless you keep up studies. Sure, but I mean - I haven't written C++ in quite a few years. Nor have I written PHP in a few years. But you know what? I can at least cobble together a PSEUDOCODE FizzBuzz (or hack together a mostly-legible for() loop) and that's the thing. When people fail FizzBuzz it isn't 'whoops forgot a semicolon! it's "i can't even start to write the broad-strokes logic".
|
# ? Jun 18, 2016 02:42 |
|
i have interviewed lots of people and i would say 95% of people can write a fizzbuzz? do people really have different experiences? there was the famous spolsky article where he was interviewing for a technical finance person, and most people had finance backgrounds, not programming backgrounds
|
# ? Jun 18, 2016 04:22 |
Suspicious Dish posted:i have interviewed lots of people and i would say 95% of people can write a fizzbuzz? I am also questioning where companies are finding so many candidates who can't at least sketch out a reasonable approximation of something like FizzBuzz. This sounds more like, "putting people on the spot to code useless poo poo is a bad test of their actual abilities."
|
|
# ? Jun 18, 2016 04:41 |
|
Centripetal Horse posted:I am also questioning where companies are finding so many candidates who can't at least sketch out a reasonable approximation of something like FizzBuzz. This sounds more like, "putting people on the spot to code useless poo poo is a bad test of their actual abilities." Tbf, fizz buzz can be solved with a loop and the modulo operator; not exactly bleeding edge stuff there. My favorite solution is the one that crashes the compiler and makes it vomit the answer in the error log though.
|
# ? Jun 18, 2016 05:29 |
leper khan posted:Tbf, fizz buzz can be solved with a loop and the modulo operator; not exactly bleeding edge stuff there. My favorite solution is the one that crashes the compiler and makes it vomit the answer in the error log though. Heh, that sounds like a pretty great solution. I've never actually been asked to do a FizzBuzz-type task. I am only familiar with it because I've read about it (I might have tried it, once; I don't recall.) It occurred to me that I might be a lovely programmer who can't do FizzBuzz, so I took a stab: code:
|
|
# ? Jun 18, 2016 05:43 |
|
Centripetal Horse posted:Heh, that sounds like a pretty great solution. Too many \n if I read it correctly.
|
# ? Jun 18, 2016 06:06 |
|
Centripetal Horse posted:Heh, that sounds like a pretty great solution.
|
# ? Jun 18, 2016 07:11 |
|
Not FizzBuzz, but I have yet to find a candidate that could code up a bit counter*, in any language or even pseudocode, in the ~dozen interviews where I asked that question. Maybe I should be asking FizzBuzz first. * given a byte or an int or whatever the hell you want output how many bits in that thing are on ** these are for senior level coding positions
|
# ? Jun 19, 2016 04:23 |
|
|
# ? May 23, 2024 17:12 |
pigdog posted:If it's an example of how your code would look like from readability standpoint, yeah, probably. Hm. Imagine that. Infinotize posted:Not FizzBuzz, but I have yet to find a candidate that could code up a bit counter*, in any language or even pseudocode, in the ~dozen interviews where I asked that question. Maybe I should be asking FizzBuzz first. Really? You had a dozen applicants for a senior developer position, and no one could that? I know that some things, like pointers, are sort of disappearing from modern languages (or at least being hidden... hello "unsafe"), but it can't be that hard to find people who understand bitwise operations. Wouldn't this do the job? code:
Now I really want a thread where one of you hiring managers posts all the tests you've had huge failure rates on so we goons can take stabs at the problems.
|
|
# ? Jun 19, 2016 11:46 |