4 ms·
The only jobs that caught my eye were the ones that offered some type of challenge to apply (Apply Via API, Etc.) If I'm going to end up talking to someone from
by kenrikm 15y ago
The only jobs that caught my eye were the ones that offered some type of challenge to apply (Apply Via API, Etc.) If I'm going to end up talking to someone from Human Resources that's going to ask me the "Man Hole Cover" or "Lightbulb Question" then forget about it, I'm not interested in working in more stuffy corporate environments.
-(void)fizzbuzz
{
int i = 1;int t = 3;
int f = 5;int h = 101;
int z = 0;
// here we do a for loop using i and incrementing it until it's equal to z
for (i = i; i < h; i++)
{
/* we check if both i/t is equal to z and if i/f is equal to z
if both are true we log fizzbuzz in the console */
if (i % t == z && i % f == z)
{
NSLog(@"FizzBuzz");
}
//check if i/t = z and log
else if (i % t == z)
{
NSLog(@"Fizz");
}
//check if i/f = z and log
else if (i % f == z)
{
NSLog(@"Buzz");
}
// if none of them are true we just act like we're learning to count
else
{
NSLog(@"%d", i);
}
}
}
- Tyrannosaurs 15y agoDo you want a critique of that? I'm mainly interested because I'd be interested in a critique of my critique... We use Fizzbuzz as our lowest bar question and I'm curious to know what people consider significant points and what are not.
- waterlesscloud 15y agoSignificant point- Does it work? Non-significant points- everything else.
- Tyrannosaurs 15y agoDepends on what you're looking for. Does it work is the most important thing by a mile but if you've asked them to wrie production ready code then you've got to ask "how would I feel if one of my developers checked this into version control and how would it fair in a code review?" Maintainability, readability, efficiency and most significantly the candidates ability to explain why they took the approach they did. I wouldn't hold any approach against someone so long as they could talk intelligently about the trade offs and why they'd done what they'd done. Even really simple problems are a chance to see whether someone thinks about things.
- pilom 15y agoYour first comment should say "until its equal to h" not z
- Tyrannosaurs 15y agoShouldn't it say until it ceases to be less than h? Your comment supposes that the loop will increment without interference. While you'd hope that was the case, it's not necessarily true. Obviously with the loop as coded your comment is correct (that'll be the first condition that terminates the loop) but it could raise a question about whether comments should reflect the routine as written or just the section they're immediately referring to. Or indeed whether comments for something so self evident are even useful or necessary... Something I'd definitely ask in an interview if I was presented with this code, not looking for a specific answer, just looking for some indication that the candidate had (or could come up with) some vaguely informed thoughts on the subject.
- Steve_Baker 15y agoEvery time fizzbuzz comes up, someone has to post a solution it seems, but why does everyone write such huge fizzbuzz programs? for(int i=1; i <= 100; i++) printf((char *[]){"%d\n","Buzz\n","Fizz\n","FizzBuzz\n"}[((i%3==0)<<1)|((i%5)==0)], i);
- kenrikm 15y agoI posted it as a joke: http://www.codeslate.com/2007/01/you-dont-bury-survivors.html http://www.codeslate.com/2007/01/you-dont-bury-survivors.htm... However, yes it is huge it's Objective C with whitespace what do you expect? ;)
- Tyrannosaurs 15y agoSome people value readability, some compactness / efficiency. Why they do it one way or another is an occasionally interesting follow up question.
- kenrikm 15y agoI'm in the readability camp, I'm one to comment my code even if it's something simple and I also like to use verbose variable names. I always keep in the back of my mind that if someone had to pick up my code without knowing how anything was implemented they might appreciate my efforts (even if it's just a personal project that I don't plan on anyone seeing). You can't please everyone I'm sure for as many people that like it compact there are people that like the whitespace.
- fhars 15y agoA bit long, isn't it? 1_,`0:'{:[~x!15;"FizzBuzz";~x!3;"Fizz";~x!5;"Buzz";$x],"\n"}'1+!100 (Thats https://github.com/kevinlawler/kona https://github.com/kevinlawler/kona) [Edit: Found a way to shave off three chars]
- sray 15y agohttp://www.codinghorror.com/blog/2007/02/fizzbuzz-the-programmers-stairway-to-heaven.html http://www.codinghorror.com/blog/2007/02/fizzbuzz-the-progra... Pertinent passage: FizzBuzz was presented as the lowest level of comprehension required to illustrate adequacy. There's no glory to be had in writing code that establishes a minimum level of competency. Even if you can write it in five different languages or in under 50 bytes of code.