Earlier quoted context omitted.
You can see my reply to the parent comment. I always sit down and talk with the students, but for us to talk about the code, we need to be able to read the code. Unneeded comments make it significantly harder to read code. First time we talk about why I don't want "the what" comments, only "the why" comments. If they still do it in the next handin it's a fail unless they've explicitly provided me with a reasonable re…
In science, there is no such thing as why, there are only deeper levels of what. And those levels are subjective and relative to personal experience. Your comment merits a failing mark, downvotes, because you made the same subjectively wrong statement twice.
How to win the coding interview
281–290 of 305 posts
Re: How to win the coding interview
#282Earlier quoted context omitted.
I've had students that did this. It's a real pain to read code like that, and the 2nd time they handed it in, it was an automatic fail. Comments explain assumptions, and often "the why", never "the what" unless it's obscure because of optimizations.
I agree with the other commenters that say thats a bit harsh to completely fail them. I was in my third CS class in college and I left out a semi colon on a test and my teacher said, none of the code would work from here, so the answer is just 100% wrong. Even though the rest was 100% correct. I made the argument that if I was sitting at a computer, that would have been less than a 5 second mistake, or something I wo…
Re: How to win the coding interview
#283Re: How to win the coding interview
#284Earlier quoted context omitted.
Yep, should have read all the way through before posting. But the example solution is so bad anyway.
What's your preferred solution?
is_a_palindrome(S) {
assert is_a_string(S)
if reverse(S) == S
return true
return false
}
A string is a palindrome if it's equal to itself reversed. The example "solution" in the article is dreadfully overengineered to death and back. Noone interviewing should be happy to see such a solution and noone being interviewed should expect to be required to give such a solution, to such a trivial problem.Unless of course the recruiter is trying to catch you pants-down, but then the parent article wouldn't post that overengineered "solution" as a gold-standard, like they did.
Re: How to win the coding interview
#285Re: How to win the coding interview
#286Earlier quoted context omitted.
Ok, so I guess by your omission, you agree that pseudocode is not code and flow charts are also not pseudocode. I don't care about the rest, you can whiteboard all you want. We analyze the problem, then solve it in our heads, usually by the time we've finished talking about it. White boarding just seems way over the top, especially if it takes more than one person to solve a problem every day. Sounds like development…
> you agree that pseudocode is not code and flow charts are also not pseudocode What? I just demonstrated that pseudocode is an ultimate form of a code, flowcharts included (they're just a graphical pseudocode). Maybe you do not understand what does the word "code" mean? > What's 2+2? Is it an average complexity of the problems you're solving? > stack do you use? Even your choice of words betrays you. You're a web co…
No, automation with AI. DSS mostly. Stacks aren't just for web.
I guess if you are unwilling to share your stack or any information other than the fact that you write stuff on paper and don't know what pseudocode is, then we don't have much to discuss, and you haven't really made any convincing arguments to your "superior" coding methods. I've seen enough BS in my 20 years to recognize yours.
Re: How to win the coding interview
#287Earlier quoted context omitted.
> you agree that pseudocode is not code and flow charts are also not pseudocode What? I just demonstrated that pseudocode is an ultimate form of a code, flowcharts included (they're just a graphical pseudocode). Maybe you do not understand what does the word "code" mean? > What's 2+2? Is it an average complexity of the problems you're solving? > stack do you use? Even your choice of words betrays you. You're a web co…
Pseudocode has a definition, you can't just make one up in an attempt to not look foolish. No, automation with AI. DSS mostly. Stacks aren't just for web. I guess if you are unwilling to share your stack or any information other than the fact that you write stuff on paper and don't know what pseudocode is, then we don't have much to discuss, and you haven't really made any convincing arguments to your "superior" codi…
I'm using exactly the same definition: pseudocode is a made-up language which may or may not vaguely resemble some existing language features.
> Stacks aren't just for web.
Yet, only hipstors use this word in such a context.
I explained the methodology in detail. It is agnostic of a target language or even problem domain.
I'm using it even when I'm writing a pure C++ code, not just when I'm building DSLs directly.
Re: How to win the coding interview
#288Earlier quoted context omitted.
Clean, easy, maintainable. To me that is more valuable than an increase in performance. I would be very surprised to find a palindrome checker as the bottle nek in a system.
One of the interviewee questions could be "Based on the profiler output, how many times would this code execute in a typical day, to the nearest power of 10? What code will it replace?" string.reverse() and string.equals() is plenty good enough for smaller magnitudes or all-new functionality. Premature optimization just means you think you can outguess the profiler. So first you code the simplest thing that works. Th…
Re: How to win the coding interview
#2891. What language(s) does this function have to be callable from? 2. Can I write it in any language?
Rather than “Is this client side or server side JavaScript?”
Considering that I have no idea how to use a regex for this, it was very strange to read that the interviewer expected _many_ people would use a regex. Made me feel like I missed a year of school or something.
For efficiency, only half of the string needs to be tested, not the whole thing. (Edit: I realized later that the posted JS does this too. It was not obvious at first because "end" is also changing.)
Since I never actually do these things, I thought it might be fun to code one. First I wrote the simple function, pal1(). Then I wondered if Python had a built-in string reverse function, so looked that up with Google and found that it didn't. It has a klunky reversed() iterator, but there was the obtuse s[::-1] post on Stack Overflow that runs fast, so added that as an alternative. And I had to lookup the __name__ line, because I forgot the syntax of that, even though I've been writing Python (HashBackup backup program) for 7 years!
import sys
# the straightforward way, char-by-char compare
def pal1(s):
slen = len(s)
slenm1 = slen - 1
for i in xrange(slen/2):
if s[i] != s[slenm1-i]:
return False
return True
# s[:-5] === "the last 5 (or fewer) characters of s"
# s[::] === s === s[start:end:incr], where start=0, end=len(s), and incr=1
# s[::-1] === reverse(s) == s[end:start:incr], where start=0, end=len(s), and incr=-1
def pal2(s):
return s == s[::-1]
# select which palindrome function to use
pal = pal1
# test with:
# 1. null string
# 2. single char (odd length)
# 3. double char string (even length)
if __name__ == '__main__':
if len(sys.argv) != 2:
print 'usage: pal '
else:
s = sys.argv[1]
if pal(s):
print 'yep'
else:
print 'nope'Re: How to win the coding interview
#290In fact a much better way to evaluate a software developer in an interview is by asking her/him to present some examples of work they have done in the past. But don't take my word for it, read here: