...

View Full Version : Why Can't Programmers.. Program?



vinyl-junkie
03-03-2007, 07:28 PM
Just for fun, pick your favorite programming language (javscript, PHP, or whatever), time yourself and see how quickly you can code the exercise here. No cheating (e.g., looking up code syntax)!

http://www.codinghorror.com/blog/archives/000781.html

Aradon
03-03-2007, 09:10 PM
I would say I'm surprised but I'm really not. I've taught a few classes in Java and C++ and when they take the classes in the first couple years of their comp sci degree they know these things, but as they get to their senior year they are coding less and less and doing more theory instead. Because of this they lose basic skills and ideas such as thinking about the easy answer instead.

Being that I teach c++ right now I was able to code this up pretty quickly, but giving the answer would ruin it for the others ;O

gsnedders
03-03-2007, 09:44 PM
The FizzBuzz one, I assume? Took me 2 minutes to do in C (which really isn't my language…). Oh, and I assume all of you people here who are constantly saying I know nothing will say that 2 minutes is too slow, even in a language I scarcely know.

daniel_g
03-03-2007, 10:55 PM
took me about 10 seconds to do a pseudo code in my head, but I'm not going to bother writing it.
Is that really what they ask when your looking for a job in the CS field?


I would say I'm surprised but I'm really not. I've taught a few classes in Java and C++ and when they take the classes in the first couple years of their comp sci degree they know these things, but as they get to their senior year they are coding less and less and doing more theory instead. Because of this they lose basic skills and ideas such as thinking about the easy answer instead.
I'm not a CS student, but did have to take CS-I and CS-II. There is one thing that to date keeps bothering me: I got a C+ on both courses. The reason is that although I aced all labs and projects, exams were worth a lot, and I hate theory. On the other hand, I still can't believe that one friend go a B, when I know he was getting 50-70(out of 100) on all lab and projects. So at least in my case, the system is just plain wrong.

oracleguy
03-03-2007, 11:28 PM
Did it in under a minute.

However, I think part of the problem is people that say they are programmers but really aren't. Reading VB for Dummies the night before the interview doesn't count; and because there are lots of companies that don't do or have a piss poor technical interview, people like that get hired. Then when they interview at some place else when after 6 months the original company realizes they can't do anything, they get a real technical interview and even though they had a previous programming job.

chump2877
03-04-2007, 10:25 AM
Like daniel, I'm not going to bother coding that, but it would be sooo easy to do so in just a few short minutes...I guess the moral of the story is that a formal college degree is no substitute for an analytical mind...Hell, I literally slept through Sociology class in college and got a B....Just goes to show that it's not what you know, it's how you use it...ok, I'm out of cliches now...

croatiankid
03-04-2007, 01:45 PM
I've been learning C for like 2 or 3 days and did it on paper in about a minute. Then compiled it and it worked!

NancyJ
03-04-2007, 06:25 PM
I did it in 30s and about 10 lines in php. Probably not the best or cleverest solution but I was going for speed ;)

FishMonger
03-04-2007, 07:06 PM
I don't really consider myself as a true programmer, I don't have a CS degree and I only work with Perl, but have dabbled in php, and pascal. Based on the definition of being able to do the FizzBuzz test in a couple minutes, I must be a programmer. I did it less than 1 minute with of 5 lines of code, but could have shortened it to a one liner on the command line.

EDIT
lol, I only read the opening paragraph describing the program requirements. After writting my solution, went back and saw that they had several various solutions. How many of you cheated by reading those solutions before writting your own?

vinyl-junkie
03-04-2007, 08:06 PM
How many of you cheated by reading those solutions before writing your own?
I didn't look at any of the solutions posted. However, I confess that I went to the manual to get the syntax of a for loop. It had been too long since I had coded PHP; couldn't remember what the for loop looked like. :eek: I did, however, code a solution in about 2 minutes (if you overlook the for loop syntax error).

Getting back to what a few others have said, I don't know that I would lend too much credence to the number of lines of code it took for a solution. After all, a lot of languages let you write a single line of code, if that's what you wanted to do. The quality of the code is more what I would look at, but then, that gets more into subjectiveness and preferred coding style, which totally gets away from what the original objective was in the first place.

FishMonger
03-04-2007, 08:46 PM
I didn't look at any of the solutions posted. However, I confess that I went to the manual to get the syntax of a for loop. It had been too long since I had coded PHP; couldn't remember what the for loop looked like.
Ya, I really don't like the initialization syntax of the typical for loop, which is why I rarely use it. Instead, I use Perl's short hand version.

Here's my solution, which can be improved.

for $i (1..100) {
if ($i %15 == 0){print "FizzBuzz\n"}
elsif ($i %5 == 0){print "Buzz\n"}
elsif ($i %3 == 0){print "Fizz\n"}
else {print "$i\n"}
}

croatiankid
03-04-2007, 09:04 PM
in c it's also pretty simple. Knew the syntax because I learned it the day before :P

Basscyst
03-07-2007, 02:46 AM
I am this bored at work today, 1 minute 1 line of illegible code. :p



for(var i=1;i<101;i++){document.write(((i % 3==0&&i % 5==0)?i+"fizzbuzz":(i % 3==0)?i+"fizz":(i % 5==0)?i+"buzz":i)+"<br />")};

FishMonger
03-07-2007, 04:50 AM
I am this bored at work today, 1 minute 1 line of illegible code. :p



for(var i=1;i<101;i++){document.write(((i % 3==0&&i % 5==0)?i+"fizzbuzz":(i % 3==0)?i+"fizz":(i % 5==0)?i+"buzz":i)+"<br />")};

Not bad...Here's another one. It's my prior solution done as a 1 liner.

perl -e 'for(1..100){print $_%15==0?"FizzBuzz\n":$_%5==0?"Buzz\n":$_%3==0?"Fizz\n":"$_\n"}'

rmedek
03-07-2007, 05:15 AM
Pfff… amateurs! I did this in 7 seconds in BASIC. :D

Alex!
03-07-2007, 10:07 AM
Well...if you'd like a real challenge try doing the same thing in Malbolge :D

http://www.lscheffer.com/malbolge.shtml
http://scienceblogs.com/goodmath/2007/01/hellish_programming_malbolge.php#more

As for doing it in a 'normal' language(php in my case) it took me around a 20 seconds to think of how and another 40 seconds or so to write it out on paper.

Alex

VIPStephan
03-07-2007, 12:16 PM
How stupid is that? :D

liorean
03-07-2007, 02:34 PM
47 seconds:
function fizzbuzz(start,end){
var
i=start-1,
a=[];
while(end>=++i)
a.push(
(i%15)?
(i%5)?
(i%3)?
i:
'Fizz':
'Buzz':
'FizzBuzz');
return a;
}
alert(fizzbuzz(1,100));(well, the original had 1 and 100 hardcoded and wasn't a function, but anyway)

phoenixshade
03-08-2007, 11:27 AM
Well...if you'd like a real challenge try doing the same thing in Malbolge :D
My God, that language is just SICK! I wish I'd never seen it, because something just broke in my brain, and now I will waste approximately 01121020 hours trying to build my own implementation of "Hello World."

Karen S. Garvin
03-08-2007, 03:36 PM
There is a claim that the '99 bottles of beer' program has been written in Malbolge.

No, more like trying to code in Malbolge would make you want to drink 99 bottles of beer...

By the way, I did that other coding last month, while walking through 3 feet of snow, uphill, with no shoes on... :p

well, not really...

oracleguy
03-08-2007, 05:10 PM
No, try writing it in this language: http://compsoc.dur.ac.uk/whitespace/

rmedek
03-08-2007, 05:13 PM
That's awesome! I'm trying to work with it, but I'm getting stuck around lines 200–204. Can someone take a look?

oracleguy
03-08-2007, 06:17 PM
My favorite part is:


It's also easy to encrypt your programs. Simply write a misleading comment!

Aradon
03-08-2007, 07:06 PM
No, try writing it in this language: http://compsoc.dur.ac.uk/whitespace/


Wow, I have an open ended project in graduate school right now, I should figure out how to write the program in this language..

But is it turing complete?

EDIT:

My favorite comment: "And here I thought you were working hard on your thesis."

liorean
03-08-2007, 07:17 PM
But is it turing complete?It's claimed to be. I think it would be considerably easier to look at the whitespace language as assembly code and compile to it from a higher level language though.

the-dream
03-12-2007, 02:28 AM
done it in bout 30 secs in PHP
took me about 2 mins in JS



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum