News for hackers. Stuff that matters.
Re:Interview Zen, tool for asynchronous coding interviews by shanelja on Thursday September 13, 2012 @09:55AM (#4516119)
It's certainly not perfect, but I came up with it under pressure in less than 90 seconds without checking online for the modulo return values, so I'm rather proud of it.

<?php

$x = 1;

while($x <= 100) {

if((($x % 5) == 0) && (($x % 3) != 0)){ print("Buzz"); }else{ if(($x % 3) == 0){ if(($x % 5) == 0) { print("FizzBuzz"); } else { print("Fizz"); } }else{ print($x); }} ++$x; }

?>

Re:Interview Zen, tool for asynchronous coding interviews by lifeisstillgood on Thursday September 13, 2012 @11:14AM (#4516540)
I am a bit lost on the syntax, but its always good to check for division by 15 first. You have sort of caught that I think in 5 and not 3, but that just seems an odd idiom.

The homepage shows a simple example in C.

Oh, I used to use this on coding tests, the first guy who asked can I do it recursively in Scheme - I could have kissed him !

Re:Interview Zen, tool for asynchronous coding interviews by PhearTheCeal on Thursday September 13, 2012 @12:54PM (#4517221)
My python solution:

  print "\n".join(["Fizz"*(i%3==0)+"Buzz"*(i%5==0)+str(i)*(i%5!=0 and i%3!=0) for i in range(1,101)])