by chrisbennet · 11y ago · 0 comments
I wish I could do more tasks like this which really tests real-world problems in jobs rather than valueless Fibbonacci's sequence.
The company was Krakow Office of Base CRM. Unfortunately, I do not work there. https://getbase.com/
for (1..100) {
my $fizz = ($_ % 3 == 0) ? "Fizz" : "";
my $buzz = ($_ % 5 == 0) ? "Buzz" : "";
($fizz ne "" || $buzz ne "") ? print "$fizz$buzz\n"
: print "$_\n";
}
and the "bad" code is the one-liner: print ( ((($_ % 3) ? "" : "Fizz") . (($_ % 5) ? "" : "Buzz"))
|| $_, "\n") for (1..100);
or is the following: #!/usr/bin/perl
@v=(0, "Fizz", "Buzz", "FizzBuzz");
for($v[0]=1;$v[0]<=100;$v[0]++){
$k = ($v[0]%3)?0:1;
$k += ($v[0]%5)?0:2;
print($v[$k]."\n");
}
(All three from http://c2.com/cgi/wiki?FizzBuzzTest .)What does that reveal about the interviewee that makes this a great interview topic? To my eye, I prefer #1, #3, and #2, but it starts to get into personal preference rather than anything seriously indicative.
Do you want to dock someone for not being able to give a seriously bad implementation?
I ask because I struggled coming up with a horrible implementation of FizzBuzz. My best attempt was to have Python create a sqlite table then use SQL to do the test. Such implementations occur all too frequently at http://thedailywtf.com/ .
But surely this would not be an example of great understanding of either Python or SQL. Therefore, I don't see how you can draw your conclusion.
Could you explain more fully?