News for hackers. Stuff that matters.
Re:Want good programmers? Then pay them. by kragen on Thursday May 03, 2012 @05:29PM (#3925916)
I wonder if there's a harder equivalent to FizzBuzz — one that doesn't take any longer to explain or do, but requires a much higher level of skill to pass. One we used at http://airwave.com/ was "Write a Perl subroutine to determine whether a string is a valid dotted-quad IP address," which is something you can do in various reasonable ways in one to five lines of code.
Re:Want good programmers? Then pay them. by Natsu on Saturday May 05, 2012 @01:39AM (#3931454)
Is that really so much harder? Somehow, I expect you'd get a lot of opaque regexes like:

  sub isIP {
    return (shift =~ m/^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$/)? 1 : 0;
  }
Re:Want good programmers? Then pay them. by kragen on Sunday May 06, 2012 @01:15PM (#3935608)
I think we did get someone solving it that way once, and modulo Unicode, it's arguably a reasonable solution. But there are other one-line solutions that are more transparent.

The Stanford CS Ph.D. candidate whose solution included a Perl function for converting decimal numbers of up to three digits to binary was rejected.

Re:Want good programmers? Then pay them. by kragen on Tuesday May 08, 2012 @03:22PM (#3945378)
I failed to note in my earlier comment that yes, it is so much harder. Fizzbuzz requires that you write a loop, print some strings, and either maintain a couple of counters or use the modulo operator. Your solution requires:

- writing a subroutine

- understanding Perl parameter passing

- understanding Perl regexps, including =~, anchoring, alternatives, metacharacter escaping, character classes, and repeat counts;

- the ternary operator.

And then you could probe things like:

- Do they know how to fix the bug in your version where it incorrectly accepts an IP address with a newline appended to it?

- Do they know it would still work without the return and the ?1:0?

- Can they figure out that they could simplify and clarify the code substantially with qr?

- Do they understand why someone might prefer a non-regexp-based approach? :)

Re:Want good programmers? Then pay them. by mseebach on Friday May 04, 2012 @06:21AM (#3927786)
There are plenty, and yours is a good example of one. In fact I think actual FizzBuzz is not used much in the wild any more as it's too well known and thus drillable.