• (disco) in reply to boomzilla

    I think I had a Blakeyrat's Law about that fizzbuzz thing didn't I? I can't recall now.

  • (disco) in reply to blakeyrat

    That should be a project for you: a website codifying Blakeyrat's Laws where we can all gaze and admire them.

    Filed under: Or something anyway.

  • (disco)

    Oops, I found a problem in mine, I fixed it though. Of course, no one in there right mind would do it this way, but so what?

    OTOH, if I ever get Thelema going, I might be able to do this:

    (def fizzbuzz
      (fn (n :domain (zero? (mod n 15)))
        :co-domain String
        "FizzBuzz")
    
    (def fizzbuzz
      (fn (n :domain (zero? (mod n 3)))
        :co-domain String
        "Fizz")
    
    (def fizzbuzz 
      (fn (n :domain (zero? (mod n 5)))
        :co-domain String
        "Buzz")
    
    (def fizzbuzz
      (fn (n :domain Integer)
        :co-domain String
        (integer->string n))
    
    (def print-fizzbuzz 
      (proc (n)
        (for x 1 n)
          (system%console%print (fizzbuzz x))) 
    

    (In Thelema, the optional ':domain' and ':co-domain' specifiers are generalizations of parameter and return types; all functions and procedures are generic, and at runtime the arguments are filtered to go to the most specific sub-routine that they match.)

    Filed under: Not as if anyone gives a shit anyway...

  • (disco) in reply to blakeyrat
    blakeyrat:
    I can't recall now.

    This is my surprised post.

  • (disco) in reply to EvanED

    wait.... you....

    Goddess preserve us, you're abusing recursive exec calls that self modify their own source code!

    Filed under: Please excuse me, i need to go hide under a rock to avoid the monster you unleashed

  • (disco)
    IT'S SHOWTIME
    HEY CHRISTMAS TREE COUNTER
    YOU SET US UP 1
    STICK AROUND COUNTER <= 100
    BECAUSE I'M GOING TO SAY PLEASE COUNTER % 15 = 0
    TALK TO THE HAND "FizzBuzz"
    BULLSHIT
    BECAUSE I'M GOING TO SAY PLEASE COUNTER % 5 = 0
    TALK TO THE HAND "Buzz"
    BULLSHIT
    BECAUSE I'M GOING TO SAY PLEASE COUNTER % 3 = 0
    TALK TO THE HAND "Fizz"
    BULLSHIT
    TALK TO THE HAND COUNTER
    YOU HAVE NO RESPECT FOR LOGIC
    YOU HAVE NO RESPECT FOR LOGIC
    YOU HAVE NO RESPECT FOR LOGIC
    GET TO THE CHOPPER COUNTER
    HERE IS MY INVITATION COUNTER
    GET UP 1
    ENOUGH TALK
    CHILL
    YOU HAVE BEEN TERMINATED
    
  • (disco) in reply to ScholRLEA
    ScholRLEA:
    EDIT: removed a little bit of redundancy. HTH.

    And left a lot of it.

    Filed under: with friends like you, scheme doesn't need enemies

  • (disco) in reply to antiquarian

    Well, yeah, I was having fun rather than really solving it in the easiest way possible.

  • (disco)

    Reminds me a candidate (actually, a PhD candidate, from Texas) whom I interviewed when I was in Google.

    She said in her resume she implemented binary internet search. When I asked for details, she explained that she was looking for binary files on the internets.

  • (disco)

    Inexperienced developer can't do FizzBuzz. So?

  • (disco) in reply to chubertdev

    Inexperienced developer does crazy arsed shit instead of even attempting to solve it logically.

    Meanwhile, Jeff is preaching that we shouldn't use FizzBuzz as a test of developer competence.

  • (disco) in reply to ScholRLEA

    Looks like multimethods.

  • (disco) in reply to Bort

    Basically, it is, except that it can be applied to any function or procedure, not just those specifically marked as generic, and can dispatch by a predicate criterion as well as by type.

    The questions now are, can I make it work, and how much of a performance hit will it cause?

  • Nekminnit (unregistered)

    I think Discourse won. The world is ending. Run for the hills!

  • (disco) in reply to Arantor
    Arantor:
    Meanwhile, Jeff is preaching that we shouldn't use FizzBuzz as a test of developer competence.

    It depends on what you mean by competence. FizzBuzz is there to tell you if the candidate is on the same level as Paula Bean. Further tests are needed to determine if the developer is competent.

  • (disco) in reply to ScholRLEA

    So every function is a multimethod? I've considered that before. Not sure how necessary it is.

    ScholRLEA:
    The questions now are, can I make it work, and how much of a performance hit will it cause?

    You mean you're implementing a language with this feature?

  • (disco) in reply to Bort

    That's my eventual goal, yes.

  • (disco) in reply to EvanED
    EvanED:
    if 1 % 15.0 == 0.0: print "fizzbuzz"

    I hate every person that does this version (no real rhyme or reason why, i just feel like hating them).

    Now for the obligatory asshat js/jquery version (lacking pretty fizzbuzz formatting, but accomplishing the goal):

    var ENTERPRISE_FIZZ_CONSTANT = "fizz";
    var ENTERPRISE_BUZZ_CONSTANT = "buzz";
    
    $(document).ready(function(){
       for(i=1;i<100;i++){
          var toPrint = i;
    
          if(i%3 == 0)
             toPrint += ENTERPRISE_FIZZ_CONSTANT;
          if(i%5 == 0)
             toPrint += ENTERPRISE_BUZZ_CONSTANT;
    
          $("body").append("
    "+toPrint+"
    "); } });
  • (disco) in reply to darkmatter

    Your implementation is faulty. The numbers should not be printed when divisible by 3 or 5, yet your implementation outputs:

    1 2 3fizz 4 5buzz 6fizz 7 8 9fizz 10buzz 11 12fizz 13 14 15fizzbuzz

    +1 for effort ;)

    The below modified version should do the trick:

    var ENTERPRISE_FIZZ_CONSTANT = "fizz";
    var ENTERPRISE_BUZZ_CONSTANT = "buzz";
    $(document).ready(function(){
       for(i=1;i<100;i++){
          var toPrint = "";
          if(i%3 == 0)
             toPrint += ENTERPRISE_FIZZ_CONSTANT;
          if(i%5 == 0)
             toPrint += ENTERPRISE_BUZZ_CONSTANT;
          if(toPrint == "")
            toPrint = i;
          $("body").append("<div>"+toPrint+"</div>");
       }
    });
    
  • (disco) in reply to abarker

    No, clearly the right way to go about it is to use the first script but then go through it to remove the numbers before the fizz and the buzz!

    var ENTERPRISE_FIZZ_CONSTANT = "fizz";
    var ENTERPRISE_BUZZ_CONSTANT = "buzz";
    $(document).ready(function(){
       for(i=1;i<100;i++){
          var toPrint = i;
          if(i%3 == 0)
             toPrint += ENTERPRISE_FIZZ_CONSTANT;
          if(i%5 == 0)
             toPrint += ENTERPRISE_BUZZ_CONSTANT;
          $("body").append("<div>"+toPrint+"</div>");
       }
      // fixes Bug #23431: Stop showing numbers in places they don't apply to!
      $("div").each(function(){ $(this).html($(this).html().replace("/^\d+?(\w)/s","$1")); }); 
    });
    

    Filed Under: Had to use Regex for bonus-points but am too lazy to actually test the code. Improvements might be possible!

  • (disco) in reply to faoileag

    I think he was just writing down portions of his thoughts in random notation.

    "Loop from 1 to 100" -> "1-100" "..must be divisible by 3" -> "/3"

    and so on...

  • (disco)
  • (disco) in reply to zenmumbler
    zenmumbler:
    It looks awesome and science-y on paper and makes no sense whatsoever; perfect for Hollywood.

    I have all the specs and diagrams at home.

  • (disco) in reply to darkmatter
    darkmatter:
    I hate every person that does this version (no real rhyme or reason why, i just feel like hating them).

    You do have a reason, probably the same as mine:

    Let's say it's not just FizzBuzz in real life, it's FizzBuzzQuackRing, %3, %5, %7, %9.

    Now instead of just checking for 15, you're also checking for: 21, 27, 35, 45, 63, 105...

    I very much prefer your way.

  • (disco)
    John_Howard:
    Very tasty article!

    What to see funny things? <elided>

    But... but we were supposed to be absolutely secure against spammers! YOU LIED TO US, JEFF! YOU LIED TO US!


    Edit - PJH:

    if you're going to quote the spam posts, at least take the URL's out please? Ta.

  • (disco) in reply to riking

    Feature Request: Dislike Button

    Filed under: Yeah, I know, it's been requested already

  • (disco) in reply to abarker
    abarker:
    Your implementation is faulty. The numbers should not be printed when divisible by 3 or 5, yet your implementation outputs:

    It does not say they should not be printed in the article. The way I read it implies they should be printed every single line. I am merely following specs.


    Filed Under: WORKINGASDESIGNED, CLOSEDWONTFIX
  • (disco) in reply to Maciejasjmj
    Maciejasjmj:
    But... but we were supposed to be absolutely secure against spammers! YOU LIED TO US, JEFF! YOU LIED TO US!
    [image]
  • (disco) in reply to antiquarian

    Speaking of things you're going to dislike...

    Filed Under: BWAHAHAHAHAHA!

  • (disco) in reply to ScholRLEA

    Damn, I entered that thread and immediately began to write a solution in Excel to post. Only after did I realize you need an account to post. Fuck'em.

    =IF(AND(EXACT(MOD(ROW();3);0);EXACT(MOD(ROW();5);0));"FizzBuzz";IF(EXACT(MOD(ROW();3);0);"Fizz";IF(EXACT(MOD(ROW();5);0);"Buzz";ROW())))
    
  • (disco) in reply to riking

    last post 21+ days ago... first post 7 years ago... why do you necro? via a screenshot of text (missing wooden table even) Very Much Doing It Wrong™

  • Hannes (unregistered)
    private void print(string output)
    {
         Console.WriteLine(output);
    }
    
    private void fizzBuzz()
    {
         print("1");
         print("2");
         print("Fizz");
         print("4");
         print("Buzz");
         print("Fizz");
         print("7");
         print("8");
         print("Fizz");
         print("Buzz");
         print("11");
         print("Fizz");
         print("13");
         print("14");
         print("FizzBuzz");
         //...you get the idea
    }
    

    Best solution ever.

  • (disco)
    John_Howard:
    Very tasty article!

    What to see funny things? http://www.example.com

    Yup. Just as I suspected. You can't quote a hidden article when replying via the "reply" button, but of course you can when you reply via "quote reply".

    Discoursistency!

  • (disco)
    John_Howard:
    tasty
    That's an odd way to word it.
  • (disco) in reply to riking

    Replying to @riking's post with The FizzBuzz Solution Dumping Ground which at the time of writing can't be quoted via the mechanisms Discourse provides.

    Isn't it funny that in the thread solutions #3 and #4 both don't work to spec because the numbers are not printed?

    And that #5 seems to be coded in a language that doesn't provide an else clause to the standard if?

    Also: for (int i = 1; i = 100; i++) - If I remember correctly, the ommission of < in the test leads to an assignment, and the test testing the result of the assignment, resulting in an endless loop?

    To me that proves that the FizzBuzz test is there for a reason.

  • (disco)

    Oh Discourse, why is your handling of the Enter key so wrong ...

  • (disco) in reply to aliceif
    aliceif:
    John_Howard said: >tasty

    That's an odd way to word it.

    I'm at work right now... I decided *not* to follow that link.
  • (disco) in reply to faoileag

    It's apparently an image sharing site. For memes and such. Probably a good idea to not visit it, ever.

  • (disco) in reply to aliceif

    If you wanna piss everybody here off, following - and using the images from - a memesite is probably the best way to go!

    Filed Under: You could also program a forum. That works well, too!

  • (disco) in reply to Kuro
    Kuro:
    If you wanna piss everybody here off, following - and using the images from - a memesite is probably the best way to go!

    Filed Under: You could also program a forum. That works well, too!

    For best results, combine both approaches!
  • (disco) in reply to faoileag

    Given that I have been known to use the odd meme image and program a forum... shiiiiiiiiiiiiiiiiiiit.

  • (disco) in reply to John_Imrie
    John_Imrie:
    Surly you can build an equality test from an 'is zero' operator.

    Only if you also have decrement. It's been proven (CBA to look up the ref) that the combination of increment, decrement-and-branch-on-zero and two infinite-precision unsigned integer variables is turing complete. (I suppose you might also need a literal goto so you can linearise the control state graph into a textual form, but that's trivial.)

  • (disco)

    This is amazing. Looks like an individual's attempt to cargo cult software development. How could you have let him go? I wanna see more. He should be put in a fake job position and studied by scientists. Fuck, would that be awesome.

  • (disco)

    c# console application implementation of FizzBuzz in one line

    for (int i = 1; i <= 100; i++) Console.Write(((i % 3 == 0 || i % 5 == 0) ? ((i % 3 == 0) ? "Fizz" : "") + ((i % 5 == 0) ? "Buzz" : "") : i.ToString()) + "\n");
    
  • (disco)

    cartman's rule #1: Any discussion where fizzbuzz is mentioned, no matter how tangentially, will eventually turn into a fizzbuzz implementation contest.

  • (disco) in reply to cartman82

    Can i hear it for a fizzbuzz golf competition?

    shortest code wins, most WTF code wins runner up.

  • (disco) in reply to faoileag

    By all your powers combined, you become... Alex Papadimoulis!

  • (disco) in reply to accalia
    accalia:
    Can i hear it for a fizzbuzz golf competition?

    shortest code wins, most WTF code wins runner up.

    No, most WTFs per line wins. What they win has yet to be decided, and will probably depend on what those nice men with the very long sleeved jacket have to say…
  • (disco)

    Someone able to read the class name? Can't quite decipher it. Lacste?

  • (disco) in reply to Mathias

    Locate Trust me, I'm an expert at deciphering bad handwriting.

Leave a comment on “The Fizz Buzz from Outer Space”

Log In or post as a guest

Replying to comment #:

« Return to Article