For instance, you may be able to get a programming job without at any point being asked to produce a code portfolio or to program in front of an interviewer.
I’d still be keen, by the way, to help you through a specific example that’s giving you trouble compiling. I believe that when smart people get confused by things which their designers ought to have made simple, it’s an opportunity to learn about improving similar designs.
HAI
CAN HAS STDIO?
I HAS A VAR
IM IN YR LOOP
UP VAR!!1
IZ VAR LEFTOVER 15 LIEK 0?
YARLY VISIBLE "FizzBuzz"
NOWAI IZ VAR LEFTOVER 3 LIEK 0?
YARLY VISIBLE "Fizz"
NOWAI IZ VAR LEFTOVER 5 LIEK 0?
YARLY VISIBLE "Buzz"
NOWAI VISIBLE VAR
KTHX
IZ VAR NOT SMALR THAN 100? KTHXBYE
IM OUTTA YR LOOP
KTHXBYE
It might help to note that dialects—and I don’t see any reason not to consider both the various kinds of ‘netspeak and the various programming languages as such, in most cases of human-to-human interaction—are almost exclusively used as methods of signaling cultural affiliation. In this case, I parsed Bogus’ use of ‘netspeak as primarily an avoidance of affiliation with formal programming culture (which tends to linger even when programs are set out in standard English, in my experience), and secondarily a way of bringing in the emotional affect of the highly-social ’netspeak culture.
It is ‘mammal stuff’, but it seems to be appropriate in this instance, to me.
Thanks. I was mostly kidding, but I appreciate the extra perspective.
(Signalling my own affiliation as a true geek, I actually attempted to download a LOLCODE interpreter and run it on the above, but the ones I could get my hands on seem to be broken. I would upvote it if I could run it, and it gave the right answer.)
Looks right to me, though I wound up reformatting the loop a little. That’s most likely a result of me being in the habit of using for loops for everything, and forgetting the proper formatting for other kinds, rather than being an actual flaw in the code—I’m willing to give bogus the benefit of the doubt about it, in any case.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Of course, my own draft used
if(var % 3 == 0 && var % 5 == 0)
instead of the more reasonable x%15.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Mine does, but I’m aware that it’s good coding practice to specify anyway. I was maintaining his choice.
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Yep, but I don’t remember how else to signify an intrinsically infinite loop, and bogus’ code seems to use an explicit return (which I wanted to keep for accuracy’s sake) rather than checking the variable as part of the loop.
My method of choice would be for(var=0; var<100; ++var){} (using LSL format), which skips both explicitly returning and explicitly incrementing the variable.
Evidently writing about the FizzBuzz problem on a programming blog results in a nigh-irresistible urge to code up a solution. The comments here, on Digg, and on Reddit—nearly a thousand in total—are filled with hastily coded solutions to FizzBuzz. Developers are nothing if not compulsive problem solvers.
It certainly wasn’t my intention, but a large portion of the audience interpreted FizzBuzz as a challenge. I suppose it’s like walking into Guitar Center and yelling ‘most guitarists can’t play Stairway to Heaven!’* You might be shooting for a rational discussion of Stairway to Heaven as a way to measure minimum levels of guitar competence.
But what you’ll get, instead, is a blazing guitarpocalypse.
Somehow, the other responses to this comment reminded me of that.
main = putStr . unlines $ fizzbuzz 100
fizzbuzz m = map f [1..m] where
f n | n `mod` 15 == 0 = "FizzBuzz"
f n | n `mod` 3 == 0 = "Fizz"
f n | n `mod` 5 == 0 = "Buzz"
f n = show n
I tested myself with MATLAB (which makes it quite easy) out of some unnecessary curiosity—it took me about seven minutes, a fair part of which was debugging.
% FizzBuzz - print all numbers from 1 to 100, replacing multiples of 3 with
% "fizz", multiples of 5 with "buzz", and multiples of 3 and 5 with
% "fizzbuzz".
clear
clc
for i = 1:100
fb = '';
if length(find(factor(i)==3)) > 0
fb = [fb 'fizz'];
end
if length(find(factor(i)==5)) > 0
fb = [fb 'buzz'];
end
if length(fb) > 0
fprintf([fb '\n'])
else
fprintf('%5.0f\n', i)
end
end
A better program (by which I mean “faster”, not “clearer” or “easier to modify” or “easier to maintain”) would replace the tests with something less intensive—for example, incrementing two counters (one for 3 and one for 5) and zeroing them when they hit their respective desired factors.
I wouldn’t be; I’d take it as (anecdotal) evidence that the craft of programming is systematically undertaught. By which I mean, the tiny, nano-level rules of how best to interact with this strange medium that is code.
(Recently added to my growing backlog of possibly-top-level-post-worthy topics is “how and why programming may be a usefull skill for rationalists to pick up”...)
I have to admit, I was looking up functions in the docs, too—I would have been a bit faster working in pseudocode on paper.
Edit: Also, my training is in engineering, not comp. sci. - the programming curriculum at my school consists of one MATLAB course.
(Recently added to my growing backlog of possibly-top-level-post-worthy topics is “how and why programming may be a usefull skill for rationalists to pick up”...)
Querying my brain for cached thoughts:
Programming encourages clear thinking—like evolution, it is immune to rationalization.
Thinking in terms of algorithms, rather than problem-answer pairs, and the former generalize.
I’m sorry to be the one to break the news to you, but the IT industry has appallingly low standards for hiring.
For instance, you may be able to get a programming job without at any point being asked to produce a code portfolio or to program in front of an interviewer.
I’d still be keen, by the way, to help you through a specific example that’s giving you trouble compiling. I believe that when smart people get confused by things which their designers ought to have made simple, it’s an opportunity to learn about improving similar designs.
A quick solution to the FizzBuzz quiz:
*in ur LessWrong, upvotin’ ur memez*
For the first time here I’m having a Buridan moment—I don’t know whether to upvote or downvote the above.
It might help to note that dialects—and I don’t see any reason not to consider both the various kinds of ‘netspeak and the various programming languages as such, in most cases of human-to-human interaction—are almost exclusively used as methods of signaling cultural affiliation. In this case, I parsed Bogus’ use of ‘netspeak as primarily an avoidance of affiliation with formal programming culture (which tends to linger even when programs are set out in standard English, in my experience), and secondarily a way of bringing in the emotional affect of the highly-social ’netspeak culture.
It is ‘mammal stuff’, but it seems to be appropriate in this instance, to me.
Thanks. I was mostly kidding, but I appreciate the extra perspective.
(Signalling my own affiliation as a true geek, I actually attempted to download a LOLCODE interpreter and run it on the above, but the ones I could get my hands on seem to be broken. I would upvote it if I could run it, and it gave the right answer.)
integer var
while(1)
{
++var
if (var % 15 == 0)
else if (var % 3 == 0)
else if (var % 5 ==0)
else
if !(var<100)
}
Looks right to me, though I wound up reformatting the loop a little. That’s most likely a result of me being in the habit of using for loops for everything, and forgetting the proper formatting for other kinds, rather than being an actual flaw in the code—I’m willing to give bogus the benefit of the doubt about it, in any case.
Pretty much. Both you and bogus apparently forget to put an initial value into var (unless your language of choice automatically initializes them as 0).
Using while(1) with a conditional return is a little bizarre, when you can just go while(var<100).
Of course, my own draft used if(var % 3 == 0 && var % 5 == 0) instead of the more reasonable x%15.
Mine does, but I’m aware that it’s good coding practice to specify anyway. I was maintaining his choice.
Yep, but I don’t remember how else to signify an intrinsically infinite loop, and bogus’ code seems to use an explicit return (which I wanted to keep for accuracy’s sake) rather than checking the variable as part of the loop.
My method of choice would be for(var=0; var<100; ++var){} (using LSL format), which skips both explicitly returning and explicitly incrementing the variable.
Jeff Atwood also makes this meta point about blogging about fizzbuzz:
Somehow, the other responses to this comment reminded me of that.
Somehow, I believe this is my fault for having mentioned trying it myself, and for that, I apologize.
If all you have is regex s/.+/nail/
Warning: Do not try this (or any other perl coding) at home!
I think anyone who applies to a programming job and can’t write this (in whatever language) deserves something worse than being politely turned down.
I tested myself with MATLAB (which makes it quite easy) out of some unnecessary curiosity—it took me about seven minutes, a fair part of which was debugging.
I feel rather ashamed of that, actually.
As everyone else seems to be posting their code:
A better program (by which I mean “faster”, not “clearer” or “easier to modify” or “easier to maintain”) would replace the tests with something less intensive—for example, incrementing two counters (one for 3 and one for 5) and zeroing them when they hit their respective desired factors.
I wouldn’t be; I’d take it as (anecdotal) evidence that the craft of programming is systematically undertaught. By which I mean, the tiny, nano-level rules of how best to interact with this strange medium that is code.
(Recently added to my growing backlog of possibly-top-level-post-worthy topics is “how and why programming may be a usefull skill for rationalists to pick up”...)
I have to admit, I was looking up functions in the docs, too—I would have been a bit faster working in pseudocode on paper.
Edit: Also, my training is in engineering, not comp. sci. - the programming curriculum at my school consists of one MATLAB course.
Querying my brain for cached thoughts:
Programming encourages clear thinking—like evolution, it is immune to rationalization.
Thinking in terms of algorithms, rather than problem-answer pairs, and the former generalize.