Author Topic: Can the Blockland Forums pass the Fizz Buzz test?  (Read 2600 times)

oh. oh wow i totally misunderstood that lol
Haha, why else did you think i posted all that? :P

Probably it is his homework though. >_>
EDIT: Oh wait, vacation, but who knows.

For those unaware: The "Fizz Buzz Test" is often employed by companies looking to hire new programmers. What's funny is that most Comp Sci majors our Java Programmer FactoriesEsteemed Universities churn out can't pass it.

Just for kicks, here's a FizzBuzz solution written in COBOL, a horrendous language in practically every sense of the word.

Code: [Select]
IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZBUZZ.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 CURRENT-NUMBER      PIC 999.
01 FIZZ-CHECK          PIC 9.
01 BUZZ-CHECK          PIC 9.

PROCEDURE DIVISION.
Begin.
MOVE 1 TO CURRENT-NUMBER
    PERFORM 100 TIMES.
        DIVIDE CURRENT-NUMBER BY 3 GIVING FILLER REMAINDER FIZZ-CHECK.
        DIVIDE CURRENT-NUMBER BY 5 GIVING FILLER REMAINDER BUZZ-CHECK.
        IF FIZZ-CHECK = 0
            THEN IF BUZZ-CHECK = 0
                THEN DISPLAY "FIZZBUZZ"
                ELSE DISPLAY "FIZZ"
                END-IF
                ELSE IF BUZZ-CHECK = 0
                    THEN DISPLAY "BUZZ"
                ELSE DISPLAY CURRENT-NUMBER.
        ADD 1 TO CURRENT-NUMBER
    END-PERFORM
    STOP RUN.

Edit to add: What kind of stuffty code tag doesn't use monospace? Demanding badspot stop drawing transgender research and start fixing this asap
« Last Edit: July 15, 2012, 07:32:04 AM by segfault314 »

I'll do a version using TS you can use it in blockland for extra points :)

Code: [Select]
function fizzBuzzTest(%max)
{
    for(%i=1;%i<=%max;%i++)
    {
        %print = %i;
        if(!(%i % 3))
            %print = "Fizz";
        if(!(%i % 5))
            %print = %print @ "Buzz";
        echo(%print);
    }
}
If you put this function into a valid addon folder, you can type fizzBuzzTest(100); into console to see the test

For those unaware: The "Fizz Buzz Test" is often employed by companies looking to hire new programmers. What's funny is that most Comp Sci majors our Java Programmer FactoriesEsteemed Universities churn out can't pass it.

Just for kicks, here's a FizzBuzz solution written in COBOL, a horrendous language in practically every sense of the word.

Code: [Select]
IDENTIFICATION DIVISION.
PROGRAM-ID. FIZZBUZZ.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 CURRENT-NUMBER      PIC 999.
01 FIZZ-CHECK          PIC 9.
01 BUZZ-CHECK          PIC 9.

PROCEDURE DIVISION.
Begin.
MOVE 1 TO CURRENT-NUMBER
    PERFORM 100 TIMES.
        DIVIDE CURRENT-NUMBER BY 3 GIVING FILLER REMAINDER FIZZ-CHECK.
        DIVIDE CURRENT-NUMBER BY 5 GIVING FILLER REMAINDER BUZZ-CHECK.
        IF FIZZ-CHECK = 0
            THEN IF BUZZ-CHECK = 0
                THEN DISPLAY "FIZZBUZZ"
                ELSE DISPLAY "FIZZ"
                END-IF
                ELSE IF BUZZ-CHECK = 0
                    THEN DISPLAY "BUZZ"
                ELSE DISPLAY CURRENT-NUMBER.
        ADD 1 TO CURRENT-NUMBER
    END-PERFORM
    STOP RUN.

Edit to add: What kind of stuffty code tag doesn't use monospace? Demanding badspot stop drawing transgender research and start fixing this asap
Haha, wow, i didn't know that.
I can understand that the most people who got off university don't pass this.

Because some universities just don't understand that it might be useful if you teach your students how to program on a computer science study. >_>
Just like my university.

Code: [Select]
int maxNumber = 100;
for(int i = 0; i < maxNumber;i++)
{
   string fizzorbuzz = "";
   if(i % 3 == 0) //Now we check if it is dividable by 3
   {
      fizzorbuzz += "Fizz";
   }
   if(i % 5 == 0) //Now we check if it is dividable by 5
   {
      fizzorbuzz += "Buzz";
   }
   if(fizzorbuzz != "")
      print(fizzorbuzz);
   else
      print(i);
}
(Edited it due to i forgot to print the numbers if it wasn't dividable by any of both)
The method print is filled with whatever the programming language uses to print in the console or whatever and prints the parameter.

kthnxbai.

EDIT:You guys didn't read.
But oh well.
Good job, now write it in perl and I'll be impressed.

Code: [Select]
@(sanl,0)
{i:1:100:
@(cicb)
@(ifeq,@(md,i,3),0):@(pn,Fizz)
@(ifeq,@(md,i,5),0):@(pn,Buzz)
@(ifeq,@(cicbv),0):@(pn,i)
@(pnnl)
}

now with a version for the most terrible scripting language ever

requires the following hardcoded methods:
pn; print value
pnnl; print newline
sanl; enable/disable auto newlines when printing
cicb; resets counter for bytes printed
cicbv; value of counter for bytes printed
ifeq; compares two values, if true runs the extension
md; modulo
« Last Edit: July 15, 2012, 10:02:51 AM by Port »

Code: (Python) [Select]
for i in range(1, 101):
  out = ""
  if i % 3 == 0: out += "Fizz"
  if i % 5 == 0: out += "Buzz"
  print out or i

Edit: Forgot including 100
« Last Edit: July 15, 2012, 12:20:52 PM by DontCare4Free »

I'm learning Python right now, so I might be able to do it.

I'm just lazy.

Code: (Visual Basic .NET) [Select]
Dim maxNumber As Integer = 100
For i As Integer = 0 to maxNumber Step 1
   Dim fizzorbuzz As String = ""
   If i mod 3 = 0 Then
      fizzorbuzz += "Fizz"
   End if
   If i mod 5 = 0 Then
      fizzorbuzz += "Buzz"
   End if
   If (fizzorbuzz = "") = False Then
      Console.WriteLine(fizzorbuzz)
   Else
      Console.WriteLine(i)
   End if
Next

I had to.
« Last Edit: July 15, 2012, 10:19:06 AM by Tyler66 »

Code: (Visual Basic .NET) [Select]
Dim maxNumber As Integer = 100
For i As Integer = 0 to maxNumber Step 1
   Dim fizzorbuzz As String = ""
   If i mod 3 = 0 Then
      fizzorbuzz += "Fizz"
   End if
   If i mod 5 = 0 Then
      fizzorbuzz += "Buzz"
   End if
   If (fizzorbuzz = "") = False Then
      Console.WriteLine(fizzorbuzz)
   Else
      Console.WriteLine(i)
   End if
Next

I had to.
what a surprise, a brony who writes in VB.NET

you're a real contribution to society, huh?

what a surprise, a brony who writes in VB.NET

you're a real contribution to society, huh?
easy now partner


what a surprise, a brony who writes in VB.NET

you're a real contribution to society, huh?
about as much of a contribution as an angry kid that writes in COBOL, yeah

what a surprise, a brony who writes in VB.NET

you're a real contribution to society, huh?

simmer down now

Code: [Select]
@name Fizz-stuff
@inputs
@outputs Screen:string
@persist TheInc
@trigger
 
interval(1000)
TheInc++

if(TheInc <= 100)
{
if(TheInc % 5 == 0 & TheInc % 3 == 0)
{
    Screen = "FizzBuzz"
}
elseif(TheInc % 3 == 0)
{
    Screen = "Fizz"
}
elseif(TheInc % 5 == 0)
{
    Screen = "Buzz"
}
else
{
    Screen = toString(TheInc)
}
}
Garry's Mod Wiremod Expression 2 latest-ish revision.