If You Can Code Hanoi, You Can Code Anything



  • On my week off, I went on a job interview for what on paper sounded like an interesting opportunity. The person doing the interviewing looked like he was barely out of college. After pleasantries, he handed me a written test consisting of a single question: write a program to implement Towers of Hanoi.

    I looked at him with a raised eyebrow: and? He responded that we get lots of folks who claim they can program but can't. This will conclusively prove that you are a developer.

    I said that I've been programming professionally for 30 years, and that I haven't once seen Towers of Hanoi since second level programming courses in school. If I do it correctly, you still know nothing about my ability to solve day to day business problems and design scalable applications. If I can't do it, you still know nothing about my ability to solve day to day business problems and design scalable applications. This tells you nothing about me, but tells me volumes about you.

    Well this is how we sift out the bad candidates from the good ones.

    I replied: so there's more to it than just this?

    No, this is the interview: if you can code Towers of Hanoi, you are qualified to work on this team.

    I shuddered, laughed, thanked him for his time and left.

    Based solely on their qualification procedure, I can't even fathom the plethora of living, breathing WTF that is their code base.



  •  Maybe the application and everything around it stinks, but the code is absolutely goregous...



  •  So, can you implement Towers of Hanoi?



  • @joeyadams said:

     So, can you implement Towers of Hanoi?

    As a matter of fact, when I got home, out of curiosity (and without looking it up), I tried to code it based solely on analyzing the problem description. It worked on the first try (10 LOC including terminating conditions and closing braces).



  • @joeyadams said:

    So, can you implement Towers of Hanoi?

    What does that even mean? "Can you write a computer program to move disks from one peg to another and reverse their order?" "Well, give me a robot arm and let's find out..."



  •  No what we have here is another of the unending series of whining posts,which I have been watching over the last few weeks, about how clever Mr Snoofly is and how stupid everyone else is, so here is a clue for you Snoofly, they don't give a shit about your opinion of thier test, they wanted to see if you lived up to your claims of wonderousness and could actualy program without whining about it, but you failed that, there are actualy a large number of people who claim to be wonderous when they apply for a job and don't live up to thier claims when given some simple task to perform.

    Judging by the number of whining posts from Mr Snoofles I get the impression that if I employed him I would be forced to beat him to a bloody pulp with a chair leg within a week.



  • Hey look a new troll.



  • @karly said:

     No what we have here is another of the unending series of whining posts,which I have been watching over the last few weeks, about how clever Mr Snoofly is and how stupid everyone else is, so here is a clue for you Snoofly, they don't give a shit about your opinion of thier test, they wanted to see if you lived up to your claims of wonderousness and could actualy program without whining about it, but you failed that, there are actualy a large number of people who claim to be wonderous when they apply for a job and don't live up to thier claims when given some simple task to perform.

    Judging by the number of whining posts from Mr Snoofles I get the impression that if I employed him I would be forced to beat him to a bloody pulp with a chair leg within a week.

    Judging by your English, you wouldn't be qualified to work in a HR department. And by the way you speak, it also doesn't seem like you'd ever be in a position in which you could hire most of the people who regularly post here. Hell if you even think that the Hanoi test in the OP was a good idea, I would be afraid to work in the same company as you do.



  • Hey look the new troll trolled someone.



  •  If I remember the original description for the Towers of Hanoi, it's that once the monks move all sixty-four disks from one needle to the other, the world will come to an end.

    If they actually said "if you can code Towers of Hanoi, you are qualified to work on this team", this company is evil and wants to end the world.

    They must be stopped!

     


  • BINNED

    @karly said:

    so here is a clue for you Snoofly, they don't give a shit about your opinion of thier test.

    So why did you interview him?

     



  •  No, we test prospective new employees to if they are :-

    1, Not activley psycotic

    2, Able to do what they say they can do

    3, Able to converse like a normal human being

    4, Not obsessed with whining about things which normal people live with on a daily basis.

    and finally and most importantly not some pedantic dickweed geek. 


  • Discourse touched me in a no-no place

    @snoofle said:

    Well this is how we sift out the bad candidates from the good ones.
    Strangely, this would also appear to be a way of sifting out the bad employers from the good ones....



    Remember, kids, the interview is not at one way thing - you are (well, should) interviewing the potential employer here...


  • Discourse touched me in a no-no place

    @karly said:

    No what we have here is another of the unending series of whining posts,which I
    have been watching over the last few weeks, about how clever Mr Snoofly is and
    how stupid everyone else
    Did you really say that in your first post here? Really??


  • Discourse touched me in a no-no place

    @karly said:

     No, we test prospective new employees to if they are :-

    [...]

    3, Able to converse like a normal human being

    How did you pass the test? Merely wondering ya know, since you come up with things like, I dunno, @karly said:
    some pedantic dickweed geek
    Prosecution rests.


  • I would think that after the interview they both agreed that he wasn't right for the position, even if for different reasons, and that's what matters. So, the interview 'worked'.



  • @snoofle said:

    On my week off, I went on a job interview for what on paper sounded like an interesting opportunity. The person doing the interviewing looked like he was barely out of college. After pleasantries, he handed me a written test consisting of a single question: write a program to implement Towers of Hanoi.

    I looked at him with a raised eyebrow: and? He responded that we get lots of folks who claim they can program but can't. This will conclusively prove that you are a developer.

    I said that I've been programming professionally for 30 years, and that I haven't once seen Towers of Hanoi since second level programming courses in school. If I do it correctly, you still know nothing about my ability to solve day to day business problems and design scalable applications. If I can't do it, you still know nothing about my ability to solve day to day business problems and design scalable applications. This tells you nothing about me, but tells me volumes about you.

    Well this is how we sift out the bad candidates from the good ones.

    I replied: so there's more to it than just this?

    No, this is the interview: if you can code Towers of Hanoi, you are qualified to work on this team.

    I shuddered, laughed, thanked him for his time and left.

    Based solely on their qualification procedure, I can't even fathom the plethora of living, breathing WTF that is their code base.

    Up until he said that coding ToH was the only part of the interview, I was going to call you TRWTF.  I've been programming professionally almost as long as you and I've never had any programming question in an interview that wasn't "Write code to average up a list of ten numbers" or "Reverse a string in place".  It's a valuable early filter, and if you can't do it, it *does* tell them something about your ability, it tells them you can't code your way out of a paper bag, can't analyze a problem, don't really grok recursion, a lot of things.  Don't forget that many candidates who show up for programming job interviews can't program. At all.  When you did try the test, you did ace it, after all.

    But then he went and said that that was all there was to it and proved that he wasn't just sensibly trying to weed out the worse-than-hopeless candidates after all - or, as you noted, implied that they'll take any candidate who's even only just not-quite-worse-than-hopeless.

    Still, I think you over-stated the strength of your point.  The coding test tells little about a programmer, but not nothing at all, and what it does tell may well be useful by saving you a lot of wasted time.




  • @karly said:

    pedantic dickweed geek. 
     

    If you would like to converse with someone who is not a pedantic dickweed geek, you are on the wrong site.



  • @Buffalo said:

    @karly said:

    pedantic dickweed geek. 
     

    If you would like to converse with someone who is not a pedantic dickweed geek, you are in the wrong profession.

    FTFY


  • BINNED

    How did karly even find this site?

    Maybe it went like this:
    - 'We need to find ourselves a superstar programmer'
    - 'Someone who could do ToH could probably fix all our problems, since nobody else can do it.'
    - Asks snoofle, gets told off
    - Searches the web to find out how to code ToH
    - 'Oh noes, there's this website where our interviewee rants about us. And he seems to be the king there, too.'



  • @bgodot said:

    ...the interview 'worked'.

    I respectfully partially disagree.

    If I had taken the time and coded the program as they asked, they would have offered me the job. Had I accepted, I likely would have been very unhappy and left in short order. Had that happened, from their perspective, the interview would have failed in that they would have hired someone who was qualified but would not stay.

    The only reason it worked is because I saw the potential problem and decided to walk away.

    When I interview folks for programming positions, I take into account that nobody knows everything; not them, not me; nobody. I don't care if they can't recite the manual from memory, or if they are/n't experts in this or that. I try to see how they have solved problems similar to the ones they'll face if I hire them; what architecture was used (db, messaging, caching, etc), what algorithms they used (can they speak intelligently to design, growth, performance, memory issues); how they tried to take the unknown into account (e.g.: bad data/exception handling, unexpected crashes/restarts, redundancy, failover, etc); how they would handle a situation where they were stuck (would they just sit there and thrash, would they suggest using Google, would they think to ask for help after a couple of tries). If they can intelligently speak to most of these things, they have usually already done a sufficient amount of relevant coding that I don't need to give them a programming test. So far it's worked pretty well. Just my $0.02



  • @karly said:

     No, we test prospective new employees to if they are :-

    1, Not activley psycotic

    2, Able to do what they say they can do

    3, Able to converse like a normal human being

    4, Not obsessed with whining about things which normal people live with on a daily basis.

    and finally and most importantly not some pedantic dickweed geek. 

    Regarding your points 1 and 3, I find it amusing that in the previous post you stated that you would have to "beat Snoofle into a bloody pulp".
    You obviously just failed your own criteria ;)



  • @Rhywden said:

    @karly said:

     No, we test prospective new employees to if they are :-

    1, Not activley psycotic

    2, Able to do what they say they can do

    3, Able to converse like a normal human being

    4, Not obsessed with whining about things which normal people live with on a daily basis.

    and finally and most importantly not some pedantic dickweed geek. 

    Regarding your points 1 and 3, I find it amusing that in the previous post you stated that you would have to "beat Snoofle into a bloody pulp".
    You obviously just failed your own criteria ;)

    Also point four - he's whining about someone being wrong on the internet. And, arguably point two, since those are all things he implies he can do but apparently can't.

    On the other hand, he's also plainly trolling, so what do you expect?


  • BINNED

    @MascarponeRun said:

    On the other hand, he's also plainly trolling, so what do you expect?

     

    He's not trolling, he's just butthurt.

     


  • Trolleybus Mechanic

    I've inflicted this image upon you before, but since my college hosting account is dead, once again:




  • Somehow i tend to agree with you on that snoofle... i too have been a victim of programming tests given by a customer, where the kicker questions are:

    "What is an abstract class"... and more of the sort.

    But then again... in your case, i most definitely agree with your attitude of leaving.



  • @snoofle said:

     

    If I had taken the time and coded the program as they asked, they would have offered me the job. Had I accepted, I likely would have been very unhappy and left in short order.

    You sure about that?  How long have you being in your older job?



  • @snoofle said:

    @joeyadams said:

     So, can you implement Towers of Hanoi?

    As a matter of fact, when I got home, out of curiosity (and without looking it up), I tried to code it based solely on analyzing the problem description. It worked on the first try (10 LOC including terminating conditions and closing braces).

    Any chance of showing us (me) how you did it in 10?

    It takes me 17 just to set up the pegs to be ready to play. Let alone solving it, that takes me 23 LOC.



  • @DanceMaster said:

    Any chance of showing us (me) how you did it in 10?

    How about something like this?

      public static void Hanoi(int d) {
        if (d < 3) throw new ArgumentException("Don't bother me with such trivial problems");
        int m = (2 << (d - 1)) - 1;
        Stack<int>[]] s = new Stack<int>[3];
        for (int i = 0; i < d; i++) { if (i < 3) { s[i] = new Stack<int>(); s[i].Push(d); } s[0].Push(d - i - 1); }
        for (int i = 0; i < m; i++) {
          int f = i % 3 == 2 ? 1 : 0, t = d % 2 == 0 ? (i % 3 == 0 ? 1 : 2) : (i % 3 == 1 ? 1 : 2);
          if (s[f].Peek() == d || s[t].Peek() < s[f].Peek()) { f += t; t = f - t; f -= t; }
          Console.WriteLine(f + " -> " + t);
          s[t].Push(s[f].Pop());
        }
      }
    </int></int></int>


  • Gah. In case you wonder about type errors in my code, imagine a Stack<int> in place of every Stack. The forum software thought my <int>s were tags and I could not go back and fix it because the edit period had expired by the time I had noticed...



  • @DanceMaster said:

    Any chance of showing us (me) how you did it in 10?

    It takes me 17 just to set up the pegs to be ready to play. Let alone solving it, that takes me 23 LOC.

    ASKING FOR THE CODE IS MISSING THE POINT OF THE STORY. Providing the code is only encouraging people to miss the point of the story. Missing the point of the story because you're too busy writing the code sample of 27 obsolete programming languages is one of the most absolutely irritating programmer behaviors. Please refrain.

    This is fizzbuzz all over again. Notice that nobody in that comments section could actually talk about the issue at hand because it was spammed with 517 programmers all measuring their penises by posting the fizzbuzz answer to prove how smart they are.

    If you want to do some cute programming problem, then:
    1) Create a new topic for it, one where it isn't extraordinarily off-topic
    2) Actually write up specifications, because if you do it without specs, there's no way to judge the quality of any of the solutions anyway

    And don't be annoying. Respond to the point of a post, not the example. See the forest. Not the trees.


  • ♿ (Parody)

    @blakeyrat said:

    @DanceMaster said:
    Any chance of showing us (me) how you did it in 10?

    It takes me 17 just to set up the pegs to be ready to play. Let alone solving it, that takes me 23 LOC.

    ASKING FOR THE CODE IS MISSING THE POINT OF THE STORY.

    WTF is wrong with you? Why do you think that this thread would suddenly be the turning point of the site where we maintain a laser-like focus on topic?



  • @boomzilla said:

    WTF is wrong with you? Why do you think that this thread would suddenly be the turning point of the site where we maintain a laser-like focus on topic?

    Well I was put in a bad mood, since the topic I read just before this one turned into a AIM chat log of 10-year-olds making funny boobie emoticons.

    Mainly I wrote that post so people would realize that they're engaging in EXTREMELY ANNOYING BEHAVIOR. If we're ok with that, then whatever. I'll just hit "unsubscribe." But I don't think we, as a forum, should be ok with that. Just like, in my opinion, we shouldn't be ok with a AIM chat log of 10-year-olds making funny boobie emoticons.

    Also I'm trying to coin Blakeyrat's Second Law, which reads:

    @Blakeyrat's Second Law said:

    Any anecdote based on a programming problem will result in replies from coders solving the problem, but missing the point of the anecdote.

    It's not too late to tweak the wording.


  • ♿ (Parody)

    @blakeyrat said:

    @boomzilla said:
    WTF is wrong with you? Why do you think that this thread would suddenly be the turning point of the site where we maintain a laser-like focus on topic?

    Well I was put in a bad mood, since the topic I read just before this one turned into a AIM chat log of 10-year-olds making funny boobie emoticons.

    Mainly I wrote that post so people would realize that they're engaging in EXTREMELY ANNOYING BEHAVIOR. If we're ok with that, then whatever. I'll just hit "unsubscribe." But I don't think we, as a forum, should be ok with that. Just like, in my opinion, we shouldn't be ok with a AIM chat log of 10-year-olds making funny boobie emoticons.

    Personally, I found the discussion of XBox 360 configurations pretty annoying. I can see how the emoticon thing could be annoying. But someone was actually posting some code!

    I'll accept that your post here was really a carryover from the emoticons. But I feel obligated to point out that this annoyance came from someone who loves to post about a cartoon aimed at kids under 10 years old. So I guess the problem was that the emoticons discussion was just a bit above your grade level?



  • @boomzilla said:

    But someone was actually posting some code!

    I don't see that as a good thing.

    @boomzilla said:

    So I guess the problem was that the emoticons discussion was just a bit above your grade level?

    Duh, that's why I found it annoying. They should go back to talking about Blue's Clues.



  • @blakeyrat said:

    @Blakeyrat's Second Law said:
    Any anecdote based on a programming problem will result in replies from coders solving the problem, but missing the point of the anecdote.
    It's not too late to tweak the wording.
    Maybe you should. Since on TDWTF, a thread involving a programming problem will not simply result in coders trying to solve the problem, since most participants here will already know how to solve the problem in question. If anything, it will instead be about providing the most convoluted, most obfuscated, or in any other way most WTFy solution possible.



  •  I would've provided a Tower of Hanoi implementation before walking out, just so they know what they're missing out on.



  • So is it just me who has a Whitespace solution to any conceivable programming test printed on the back of my CV?



  • @MascarponeRun said:

    So is it just me who has a Whitespace solution to any conceivable programming test printed on the back of my CV?
     

    I have a one-liner at the end of my sig.



  • @blakeyrat said:

    @DanceMaster said:
    Any chance of showing us (me) how you did it in 10?

    It takes me 17 just to set up the pegs to be ready to play. Let alone solving it, that takes me 23 LOC.

    ASKING FOR THE CODE IS MISSING THE POINT OF THE STORY. Providing the code is only encouraging people to miss the point of the story. Missing the point of the story because you're too busy writing the code sample of 27 obsolete programming languages is one of the most absolutely irritating programmer behaviors. Please refrain.

    This is fizzbuzz all over again. Notice that nobody in that comments section could actually talk about the issue at hand because it was spammed with 517 programmers all measuring their penises by posting the fizzbuzz answer to prove how smart they are.

    If you want to do some cute programming problem, then:
    1) Create a new topic for it, one where it isn't extraordinarily off-topic
    2) Actually write up specifications, because if you do it without specs, there's no way to judge the quality of any of the solutions anyway

    And don't be annoying. Respond to the point of a post, not the example. See the forest. Not the trees.

    [code]
    proc hanoi {from via to n} {
      if {$n == 1} {
        puts "$from -> $to"
      } {
        incr n -1
        hanoi $from $to $via $n
        hanoi $from $via $to 1
        hanoi $via $from $to $n
      }
    }
    
    # (.Y.)
    [/code]


  • @blakeyrat said:

    @Blakeyrat's Second Law said:
    Any anecdote based on a programming problem will result in replies from coders solving the problem, but missing the point of the anecdote.

    It's not too late to tweak the wording.

    Replace "missing" with "ignoring"



  • @lettucemode said:

    Replace "missing" with "ignoring"

    I had to shrunkify it for Twitter. How about:

    @Blakeyrat's Second Law said:

    The discussion on any anecdote based on a programming problem will contain replies from programmers solving the problem, but ignoring the actual point of the anecdote.

    Edit: I highly approve of Mystery Science Theater 3000: The Movie quotes in sigs.


  • ♿ (Parody)

    @blakeyrat said:

    How about:

    @Blakeyrat's Second Law said:

    The discussion on any anecdote based on a programming problem will contain replies from programmers solving the problem, but ignoring the actual point of the anecdote. Except where this would conflict with the First Law And only Blakeyrat will really care, but others will enjoy the discussion.

    FTFY



  • @blakeyrat said:

    I highly approve of Mystery Science Theater 3000: The Movie quotes in sigs.

    Oh hey, I just watched that one the other night.


    Into the weeniemobile! Weenieman, away!



  • That's something could come in handy right about now:  NORMAL VIEWWWW!!!



  • As someone who works at a company that does similar kinds of programming questions, it is a very useful tool.  We have about 100 applicants for every 1 we hire, and as such, we need to quickly weed out the 99.  How long it takes you to solve our programming challenges, how robust your solution is, etc. really does help to quickly narrow down the pool of candidates.

    And yes - you'd be surprised how many people will try for a programming job with no real understanding of how to code even the most trivial of tasks.



  • @Cat said:

    you'd be surprised how many people will try for a programming job with no real understanding of how to code even the most trivial of tasks.
     

    Emphasis mine.

    You must be new here. :)


Log in to reply