Easier Than Fizz Buzz – Why Can't Programmers Print 100 to 1?
thousandtyone.com
thousandtyone.com
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.
Am I coldhearted for thinkng this is were you end the interview and go back to your desk to get some work done?
They might be very nervous, having a bad day, etc.
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.. for (int i=0;i;);
printf("100\n");
printf("99\n");
/*...*/
// or if you want to be a smartass
printf("100 to 1\n"); 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.for ( int i = 0144;
or
for ( int i = 0x64;
Unfortunately, the constraint was "for ( int i = 0;". :-/
#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;
}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".
for(int i=0; i< 100; i++){ System.out.println(100-i); }
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.
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.
However I whine a lot ... but it could be that the situation is really bad at my job.
Am I hired ? :-)
for i in range(100):
print(100 - i)
(there is no 'for (int i=0;' in python, but this analogous.) print [i for i in reversed(range(101))]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
echo 100-i;for($i=0;$i<100;$i++) echo 100-$i."\n";
for($i=0;;) echo 100-$i>0?100-$i++."\n":exit;
for(int i = 0, t = 100; i < 100; i++) { Console.WriteLine(t--); }
Hint: You don't need "t".
for (i = 100; i >= 0; i-=1) { console.log(i) }