News for hackers. Stuff that matters.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by meric on Thursday April 09, 2015 @06:51PM (#9351565)
Either ways the sad reality of where the IT industry stands today is that you don't even need Fizz Buzz to differentiate a bad non-programmer from a good one - Just asking them to print 100 to 1 is usually good enough.

The point of FizzBuzz is to differentiate whether a person is a non-programmer, or a programmer. It is necessary but not sufficient to determine whether a programmer is good. It's important to note non-programmers are not necessarily bad persons, they just aren't programmers.

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by decker on Thursday April 09, 2015 @06:47PM (#9351543)
That's cool, but then again, this guy likely just failed fizz-buzz for producing a graph showing correlation.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by tempestn on Friday April 10, 2015 @02:12AM (#9352795)
Ha, that was my first thought too! Would be a lot more logical to put whining on one axis and capability on the other.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by colanderman on Friday April 10, 2015 @12:29AM (#9352590)
Suggest graphing whining on one axis and coding on the other. Graphing them both on the same axis vs. candidate # is unhelpful. (And you should never connect data points which have no meaningful interpolation with lines. It's misleading.)
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by hn_user2 on Friday April 10, 2015 @12:04AM (#9352513)
I find it interesting that they moved onto the next question after a candidate gave up on the problem after 10 minutes.

Am I coldhearted for thinkng this is were you end the interview and go back to your desk to get some work done?

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by blub on Friday April 10, 2015 @07:44AM (#9353661)
That's too harsh. We have a rule for instance that we continue the interview for a minimum time, even if the candidate is doing badly.

They might be very nervous, having a bad day, etc.

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by GregBuchholz on Thursday April 09, 2015 @08:05PM (#9351822)
Any thoughts on golfing it smaller than:

    for(int i=0;i<100;printf("%d\n",100-i++));
...I'm assuming we're talking C, with the appropriate includes, and main, etc..
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by zem on Thursday April 09, 2015 @10:13PM (#9352233)
or antigolfing it :)

    for (int i=0;i;);
    printf("100\n");
    printf("99\n");
    /*...*/

    // or if you want to be a smartass
    printf("100 to 1\n");
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by tempestn on Friday April 10, 2015 @02:14AM (#9352800)
I really hope someone tried that in the interview.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by frobozz on Friday April 10, 2015 @04:42AM (#9353121)
You can easily save one more character. The problem doesn't say anything about newlines.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by im3w1l on Friday April 10, 2015 @10:27AM (#9354506)

    for(int i=101;--i;)printf("%d\n",i);
Assuming int main(int a) we can do

    a<100&&main(a+1);printf("%d\n",a);

EDIT: missed constraint that it needs to start with for(int i=0 from article.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by ConceptJunkie on Friday April 10, 2015 @08:08PM (#9357794)
It's too bad the constraint wasn't what you said it was, because then you could do:

for ( int i = 0144;

or

for ( int i = 0x64;

Unfortunately, the constraint was "for ( int i = 0;". :-/

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by bko on Thursday April 09, 2015 @10:17PM (#9352241)
for(int i=0;i<99;printf("%d\n",101-++i));
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by im3w1l on Friday April 10, 2015 @10:23AM (#9354475)
Doesn't print 1.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by rrich on Friday April 10, 2015 @02:49AM (#9352853)
// Duff's Buzz

#include<stdio.h>

int main(){

    register count = 0x64;
    register a = 0x0;

    {
    register n = (count + 0x9) / 0xa;
    switch (a=count % 0xa) {
    case 0: do {    printf("%d\n", n*0xa+a);
    case 9:     printf("%d\n", n*0xa+a-0x1);
    case 8:     printf("%d\n", n*0xa+a-0x2);
    case 7:     printf("%d\n", n*0xa+a-0x3);
    case 6:     printf("%d\n", n*0xa+a-0x4);
    case 5:     printf("%d\n", n*0xa+a-0x5);
    case 4:     printf("%d\n", n*0xa+a-0x6);
    case 3:     printf("%d\n", n*0xa+a-0x7);
    case 2:     printf("%d\n", n*0xa+a-0x8);
    case 1:     printf("%d\n", n*0xa+a-0x9);
                } while (--n > 0x0);
    }
    }
    return 0;
}
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by golergka on Friday April 10, 2015 @02:26PM (#9356179)
Love it. Immediately shows a potential employer how readable and maintainable your code will be.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by geebee on Thursday April 09, 2015 @05:32PM (#9351185)
Couple things.

First, yeah, this should be easy.

Second, yeah, you should do almost anything other than whine. That certainly includes improving your skills.

Third, there's plenty to object to in the hiring process and work environment for many software developers, and I certainly don't think all of it should be dismissed as "whining".

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by wcdolphin on Thursday April 09, 2015 @10:42PM (#9352316)
Is there something wrong with the following? I feel like I am somehow missing the complexity of the problem. Framing it as "Count down from 100 to 1" makes the implementation read like the problem.

for(int i=0; i< 100; i++){ System.out.println(100-i); }

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by TheLoneWolfling on Friday April 10, 2015 @12:25AM (#9352580)
There isn't any complexity.

It's "just" that there are many people who don't exactly problem-solve well.

I've noticed this before. I've taken classes where people produce decent, although not great, assignments, and then turn around and get <20% on a test.

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by jbergens on Friday April 10, 2015 @06:40AM (#9353476)
I still view this as a way to separate those who can hardly program at all from those who can. It is probably not a good way to measure if anyone is a great developer. The first part should probably be possible to answer by just talking to the person and to a few people he has worked with.

Besides my main arguments agains this there is another problem with this kind of questions: when the questions become known and people start writing answers all over the net (just look at a lot of comments on this page) someone could learn the answer without being or getting good at programming.

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by nallerooth on Friday April 10, 2015 @02:25AM (#9352815)
I understand that even simple problems may seem difficult when you're under stress (being interviewed). I know that I perform a lot worse under those conditions than under "normal stress", as I have to prove myself to someone else and not just to myself. But with that said, this shouldn't be a problem for anyone who have been programming for a year or more.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by Jemaclus on Thursday April 09, 2015 @05:04PM (#9351013)
Hmm. This post seems to imply that whining correlates with poor coding abilities. I'm not sure I buy that. And as a tongue-in-cheek observation, what does taking the time to write about whining about people not being able to code mean for this guy's coding abilities? :)
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by jmnicolas on Friday April 10, 2015 @08:52AM (#9353928)
It took more time for Visual Studio to launch a new project than for me to solve the problem.

However I whine a lot ... but it could be that the situation is really bad at my job.

Am I hired ? :-)

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by dysan819 on Friday April 10, 2015 @03:48AM (#9352992)
in python

   for i in range(100):
       print(100 - i)
(there is no 'for (int i=0;' in python, but this analogous.)
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by heyalexej on Friday April 10, 2015 @07:43AM (#9353659)

    print [i for i in reversed(range(101))]
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by robkix on Friday April 10, 2015 @09:54AM (#9354251)
Why reversed range? Range is fully capable of descending [1]

You also missed the point of the exercise: start at 0 in your index, but count backward from 100 in output. So the map is 0->100, 1 -> 99, ..., 99 -> 1, 100 -> 0

[1] https://docs.python.org/2/library/functions.html#range

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by heyalexej on Friday April 10, 2015 @02:41PM (#9356292)
Soooo, I won't get the job?
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by Zikes on Thursday April 09, 2015 @05:20PM (#9351103)

    echo 100-i;
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by altern8 on Thursday April 09, 2015 @07:00PM (#9351598)
I actually got it right in under 1 minute, to my surprise...
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by ljw1001 on Friday April 10, 2015 @01:03AM (#9352664)
for (i = 0; i >-100; i--) print i + 100;
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by ljw1001 on Friday April 10, 2015 @01:10AM (#9352675)
nailed it with no whining :)
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by 0hn0 on Friday April 10, 2015 @04:39AM (#9353112)
PHP:

for($i=0;$i<100;$i++) echo 100-$i."\n";

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by 0hn0 on Friday April 10, 2015 @04:47AM (#9353139)
or

for($i=0;;) echo 100-$i>0?100-$i++."\n":exit;

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by Keloran on Friday April 10, 2015 @08:54AM (#9353935)
for (int i = 0; i < 100; i++) { int j = 100; std::cout << (j - i) << std::endl; }
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by cjbar on Thursday April 09, 2015 @10:31PM (#9352286)
Took me longer than 2 minutes, I don't use this trick very often ._.

for(int i = 0, t = 100; i < 100; i++) { Console.WriteLine(t--); }

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by jpatokal on Thursday April 09, 2015 @11:58PM (#9352502)
You're not following the rules: must start with "for(int i=0;", not "...,".

Hint: You don't need "t".

Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by cjbar on Friday April 17, 2015 @09:59PM (#9398079)
haha, yeah I realized that later, thanks :(
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by niix on Thursday April 09, 2015 @07:21PM (#9351671)

  for (i = 100; i >= 0; i-=1) { console.log(i) }
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by c17r on Thursday April 09, 2015 @07:28PM (#9351700)
You didn't read the part where your solution has to begin with "for(int i=0;" with nothing before it.
Re:Easier Than Fizz Buzz – Why Can't Programmers Print 100 t... by niix on Friday April 10, 2015 @01:48PM (#9355931)
Oops. I guess that's my demise then.