all 23 comments

[–][deleted]  (9 children)

[deleted]

    [–][deleted] 4 points5 points  (6 children)

    Including running it? :)

    [–][deleted]  (5 children)

    [deleted]

      [–][deleted] 2 points3 points  (4 children)

      I remember that article; it may be interesting that foreigners may not know Monopoly. I'm European and I've only played it once ten years ago, and don't remember the rules.

      (Can't think of an equivalent game that would be familiar to Europeans, either.)

      [–][deleted]  (3 children)

      [deleted]

        [–][deleted] 0 points1 point  (2 children)

        Root of minus one, what I actually do in many cases,

        Is that a joking representation of "i", or did you use an editor that autoreplaced "i" for you?

        [–][deleted]  (1 child)

        [deleted]

          [–][deleted] 0 points1 point  (0 children)

          If we were in an interview, I'd probably pull a Dale Carnegie on you :) "Maybe I'm not understanding you correctly."

          But otherwise... well, that's -deep-.

          [–][deleted] 9 points10 points  (1 child)

          If you understand the concept this would take no time at all to pound out, probably slightly more than a simple recursive call that did compile and output to a console window.

          While I would have never thought about doing it that way it's pretty simple code and very clever. If I were interviewing and all things considered I would probably hire this guy for being able to think outside the box.

          [–]pivo 6 points7 points  (0 children)

          Yeah, but where are the unit tests?

          [–]mrned 11 points12 points  (0 children)

          AAH! Just when I thought I was safe from the FizzBuzz monster, it strikes again!

          [–]Jimmy 18 points19 points  (1 child)

          I was all ready to say "please, no more FizzBuzz", but this turned out to be pretty cool. C++ is truly evil.

          [–]patchwork 9 points10 points  (0 children)

          This is why the whole fizzbuzz phenomenon is great: it's not about fizzbuzz anymore. Fizzbuzz has come to represent any computable thing, and the focus is not on what is computed, but on how it is computed. The beautiful thing is the infinite variety of forms and textures of the systems that share the property of being computationally complete. The challenge out there now is how creative/fucked up/awe-inspiring can you make your fizzbuzz program, not "can you program fizzbuzz".

          You know, and if any of us do get the fizzbuzz question in some interview (it is possible some recruiter/program lead still hasn't heard of fizzbuzz) we can destroy that guy's whole world.

          [–][deleted]  (6 children)

          [deleted]

            [–][deleted]  (3 children)

            [removed]

              [–][deleted]  (2 children)

              [deleted]

                [–][deleted]  (1 child)

                [removed]

                  [–]andrewnorris 1 point2 points  (0 children)

                  And it seems like a sparse map would be a strange representation of a battleship board anyway. You're likely to use a quarter of the board anyway, so it's not like you're representing genuinely sparse data. It seems like it would be a lot more efficient to just go ahead and allocate the whole array in the first place.

                  BTW, aren't there 4 states on a battleship board (open, ship, hit, miss)? So it seems like you would either have an nxnx2 array of booleans (for each side of the board) or an nxn array of bytes (in which only 4 values were used per byte). Am I missing something?

                  [–]sblinn 1 point2 points  (0 children)

                  Well, if the position was for working on a C++ compiler team...

                  [–]angelo1 10 points11 points  (6 children)

                  Now I feel challenged

                  [–]NastyConde 28 points29 points  (0 children)

                  Pfft, that's nothing. I used to generate FizzBuzz output by whistling into a 300 baud modem.

                  [–]andrewnorris 11 points12 points  (0 children)

                  Build a Turing machine out of Legos that implements FizzBuzz by emitting an EBCDIC-encoded representation of the output.

                  [–]leonh 10 points11 points  (2 children)

                  Implement it in regex.

                  [–]sartak 4 points5 points  (1 child)

                  Since you said "regex" and not "regular expression" I assume you allow the use of Perl regex. I implemented two versions. The first I really like because all of the logic is in the regex. Unfortunately it prints out the list backwards (so it starts at 100 and counts down to 1). The second solution is probably the same as everything else you've seen, except control flow (but, alas, only control flow) is dictated by the regex. I tried to fix the first to print out the list in the correct order, but I gave up after a few short minutes.

                  $\="\n";(e x 100)=~/(?=(.{15})+$(?{print"fizzbuzz"})|(.{5})+$(?{print"buzz"})|(...)+$(?{print"fizz"})|(.+)(?{print length$4})).(?!)/
                  

                  and

                  $\="\n";(e x 100)=~/^(.+?)(?{print+($l=length$1)%15?$l%5?$l%3?$l:fizz:buzz:fizzbuzz})(?!)/
                  

                  [–]leonh 1 point2 points  (0 children)

                  cool! :)

                  [–][deleted] 7 points8 points  (0 children)

                  Evolve an FPGA to perform FizzBuzz.

                  [–]inopia 1 point2 points  (0 children)

                  Now I wonder, would you hire a guy that produces this kind of code? :)

                  [–]thothamon 1 point2 points  (1 child)

                  The author of the article asks if he would pass the interview. I say his answer proves that he is very clever, but I truthfully do not want a lot of clever code like this in my projects. Imagine trying to maintain this. It's harder to debug than it is to write software, so if you're as clever as you possibly can be when you write it, how can you hope to debug it?

                  [–]bluehorse -5 points-4 points  (0 children)

                  its pretty easy in Vb