During interviews, I usually open with Fizz-Buzz. Our recruiter has apparently caught onto this and has told every candidate to research this question.
This has lead to several people memorizing any of the zillion one-liners for the solution. The problem - they almost never get the one-liner right. If you spend 15 minutes redoing your one-liner Fizz-Buzz answer, then I know you're probably not the right person for the job.
The issue is some people that memorized the one-liner did ok during the job interview, but the one-liner doesn't compile/run, so I fail them.
I've tried hinting that the best solution is the easy one that you can explain to me, but most of the candidates don't seem to listen. I've said
Please make sure you can explain this to me when you're done. This isn't a trick question, and if you use a language features that I'm not super familiar with, I'm going to type your program in and run it. If it doesn't run then I can't give you any credit for this answer. A simple solution that works is better than a 'clever' solution that doesn't.
This hasn't seemed to help, and I don't want to just come out and say. "Everyone who passed this question used if statements and modulus." Has anyone found a good way to avoid getting 'clever' solutions?
The issue: Very few people are getting past Fizz-Buzz. I think part of the problem is people trying to stand out as the clever candidate. Some of the Fizz-Buzz failures ended up demonstrating a good command of SQL and basic programming concepts like inheritance. They may have passed Fizz-Buzz had they just done it the simple way. For better or worse Fizz-Buzz is a litmus test question for me, and if you fail it, we won't hire you.
EDIT If you spend 20 minutes on Fizz-Buzz, you're not going to move forward. If you spend 5 writing a one-liner, I don't know if it works until I try to run it. Because some of the candidates do better after this question, I'm hesitant to cut the interview short like I would have for a flat-out failure.
EDIT 2 Several commenters have asked if I run each copy of Fizz-Buzz including the for/if/modulus one. If the control flow is obviously right, I don't run it.
The problem with one-liners its never been intuitively obvious what the one-liner was supposed to do. For example, one person decided to write the LINQ version of Fizz-Buzz (for a Java dev position mind you) and proceeded to ramble about how LINQ creates a set and then selects out of it. I've never had a one-liner candidate explain clearly what each command did.
The type of answer I'm looking for is
This is the for (or while) loop that will go from 1 to 100. Next, I calculate the remainders of x/3 and x/5 and store the answer here. Then I do if/else if to determine what if anything I should print.
The reason I still use Fizz-Buzz heavily despite the above issues
Even with this question being extremely popular a good minority of our candidates spend upwards of 20 minutes (occasionally the entire interview) on this question and get it wrong. If you can't create this very simple program in 5-10 minutes, I don't want to hire you.
Every simple question has a one-liner, and I've learned from experience that even simple-sounding problems can be very tricky. I don't want to make up my own as I could inadvertently create a very difficult problem that would take more than 5 minutes to solve.
Using a one-liner tells me about you. Using a one-liner from a language other than the one in the job description tells me A LOT about you. My question has to do with people who may have been couched the wrong way.
It wouldn't be that hard to memorize the for/if/if else version and Fizz-Buzz is a VERY popular question. I've tried saying pretend I'm the stupidest developer you've ever meet. You need to be able to explain the answer to me - The candidate started talking about how cool Perl regex's are (for a Java dev position).