Friday, January 29, 2010

How Difficult is it, Really?

I’ve been using an easier version of my coding question lately, because candidates have struggled so much. First I moved it from C to C# (or Java, if candidates only have a java background). Then I simplified it, a lot. The problem is simple: reverse a string using no outside libraries. This was an introductory-level when I interviewed at Microsoft but now it seems to be advanced!

I’ve had candidates waste 40, 50 lines of code answering this. They usually don’t answer the question at all (they won’t write the full function with signature, or they reverse any words w/o reversing the characters, etc.).

I tried it again last night against .NET 3.x—I wanted to make sure I wasn’t expecting too much--you know, maybe programming has changed while I’ve been in meetings! ;).

I ended up with a small challenge (converting my char[] so it returned a string—kept returning the object type), but other than that, this went really well. 15 lines of code, including curly braces and the step to convert from the input string into a char[] (no error handling; have to get to that next)

Is the question too difficult? Wanna take a stab? Can you beat 15 lines, without using string.Reverse()?

50 comments:

  1. Hi John. Assuming you're attempting to hire programmers, what you're asking is not that difficult. Here's a 10-line Java version (sorry I didn't have C# installed):

    public String reverse(String s)
    {
    assert(s != null);
    StringBuffer buf = new StringBuffer();
    for (int i = s.length() - 1; i>=0; --i)
    {
    buf.append(s.charAt(i));
    }
    return buf.toString();
    }

    It's commonly known that there can easily be differences of 10x in programmer speed / effectiveness, as a Google search for "programmer productivity 10" shows. If a programmer can't handle that request in a couple of minutes, you probably don't want them programming for you.

    At first glance my code above might seem fine, but in reality, it's not. Certain Unicode grapheme's can't fit into a single character (even though Java's char is 32-bits, with the lower 21 representing the actual character). Thus, I'd actually need to check to make sure that each character wasn't one of these two-part graphemes that would need to have the order remain intact. So, maybe it really is a harder question than I thought ;).

    ReplyDelete
  2. Hey Kaleb, good point on the unicode issue. That trips up a lot of people.

    I also agree on the coding speed comment.

    Nicely done and no, it shoudln't be that difficult.

    ReplyDelete
  3. 欣賞是一種美德~回應是最大的支持^^.................................................................                           

    ReplyDelete
  4. 在莫非定律中有項笨蛋定律:「一個組織中的笨蛋,恆大於等於三分之二。」......................................................................

    ReplyDelete
  5. 當一個人內心能容納兩樣相互衝突的東西,這個人便開始變得有價值了。............................................................

    ReplyDelete
  6. 生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    ReplyDelete
  7. 世間事沒有一樣沒有困難,只要有信心去做,至少可以做出一些成績。..................................................

    ReplyDelete
  8. 做好事,不需要給人知道,雖然只是一件微不足道的事,但我相信,這會帶給我快樂。..................................................

    ReplyDelete
  9. 感謝分享~希望有更多的好文章分享給大家.................................[/url]...............

    ReplyDelete
  10. John: I'm writing from STP but didn't quickly have your email. Would you mind emailing me?
    yhamilton@redwoodco.com

    ReplyDelete
  11. Your Blog is one of the best top 100 software testing blogs listed in this article:
    http://www.testingminded.com/2010/04/top-100-software-testing-blogs.html
    but for me, it's just one of the best! Keep the great work!
    ------------------
    If you plan to go in Cameroon, please visit: Offres d'emploi au Cameroun

    ReplyDelete
  12. We develop software help desk, remote support, inventory and IT asset management, easy to implement and use. We wish that you kept abreast of all the innovations that have been made today. If you want more information can be found in*http://www.leverit.com

    ReplyDelete
  13. wonderful information, I had come to know about your blog from my friend nandu , hyderabad,i have read atleast 7 posts of yours by now, and let me tell you, your website gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a ton once again, Regards, QA online trainingamong the QA in Hyderabad. Classroom Training in Hyderabad India

    ReplyDelete


  14. SWIFT Interview questions on

    http://testwithus.blogspot.in/p/swift.htm

    For selenium solution visit
    http://testwithus.blogspot.in/p/blog-page.html

    For QTP interview questions

    http://testwithus.blogspot.in/p/qtp-questions.html

    www.searchyourpolicy.com

    ReplyDelete
  15. Resources like the one you mentioned here will be very useful to me! I will post a link to this page on my blog. I am sure my visitors will find that very useful.
    Hadoop training

    ReplyDelete
  16. Coding represents the entire world for some of us and a total mistery for others. That's way life is so coloured.

    Pentru cei care au nevoie de achizitionarea mai multor imprimante, magazinele de imprimante second hand sunt cele mai eficiente alegeri.

    ReplyDelete
  17. Thank you for sharing this article .it is very helpul

    ReplyDelete