Computer Science Canada Fizz-Buzz: The Multi-Language Challenge |
Author: | haskell [ Sat Mar 24, 2007 1:44 pm ] | ||
Post subject: | Fizz-Buzz: The Multi-Language Challenge | ||
Task To write the same program in as many languages as possible. Purpose So people can see the same code written in as many languages as possible. The Program Count from 1-100 and write the results. If the value is divisible by 3, than write "Fizz". If the value is divisible by 5, than write "Buzz". If the value is divisible by both 3 and 5, than write "FizzBuzz". Rules State the language. Multiple solutions in the same language is acceptable. Use any means necessary ![]() Enjoy ![]() --- C++
|
Author: | ericfourfour [ Sat Mar 24, 2007 2:02 pm ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | rdrake [ Sat Mar 24, 2007 2:02 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
I think this is what it should do...
|
Author: | wtd [ Sat Mar 24, 2007 2:11 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | wtd [ Sat Mar 24, 2007 2:22 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | haskell [ Sat Mar 24, 2007 2:32 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
C
|
Author: | wtd [ Sat Mar 24, 2007 2:51 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | PaulButler [ Sat Mar 24, 2007 4:07 pm ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
In Java:
|
Author: | PaulButler [ Sat Mar 24, 2007 4:11 pm ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | haskell [ Sat Mar 24, 2007 4:21 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
Python
|
Author: | wtd [ Sat Mar 24, 2007 4:25 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I don't get why so many people have such apparent loathing for "else" and such irrational love of mutable state. |
Author: | ericfourfour [ Sat Mar 24, 2007 4:53 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
wtd what were the programming languages you used? |
Author: | wtd [ Sat Mar 24, 2007 5:20 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I was hoping someone would try to guess... Ada, Eiffel, and Scala. |
Author: | richcash [ Sat Mar 24, 2007 8:36 pm ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
In javascript in html :
P.S. Javascript is not a programming language, it's a scripting language. |
Author: | wtd [ Sun Mar 25, 2007 12:24 am ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
Javascript most certainly is a programming language. A darn good one, too. |
Author: | richcash [ Sun Mar 25, 2007 2:02 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
Oh, I just go by what I read, and I know some people don't consider it to be a real programming language but rather a scripting language because its actions are handled by the web browser. If you say it's a programming language, then I agree, because I also like javascript a lot. ![]() Here's another language used in html documents :
|
Author: | wtd [ Sun Mar 25, 2007 8:33 am ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
Can you write a program in Javascript? Yes. Well, then... it's a programming language. "Scripting language" is most frequently a derogatory language thrown around by users of heavyweight languages (C, C++, Java, C#, etc. you know who you are) to make themselves feel better about their choice of programming language, as opposed to those who use more lightweight languages. Those of us who use both types of language think the whole dichotomy is pure bull crap. |
Author: | PaulButler [ Sun Mar 25, 2007 9:19 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
C#
|
Author: | wtd [ Sun Mar 25, 2007 9:36 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
Or perhaps we could just write the straightforward C# program...
|
Author: | md [ Sun Mar 25, 2007 10:32 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | PaulButler [ Sun Mar 25, 2007 10:35 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | PaulButler [ Sun Mar 25, 2007 11:12 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
(PS. this is my first O'Caml program, any tips wtd?) |
Author: | PaulButler [ Sun Mar 25, 2007 11:23 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
O'Caml with recursion instead of imperative syntax - still wondering if this could be more O'Camlized. |
Author: | PaulButler [ Sun Mar 25, 2007 11:34 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | md [ Sun Mar 25, 2007 1:51 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | haskell [ Sun Mar 25, 2007 5:29 pm ] |
Post subject: | Re: RE:Fizz-Buzz: The Multi-Language Challenge |
wtd @ Sun Mar 25, 2007 10:03 am wrote: Can you write a program in Javascript?
Yes. Well, then... it's a programming language. "Scripting language" is most frequently a derogatory language thrown around by users of heavyweight languages (C, C++, Java, C#, etc. you know who you are) to make themselves feel better about their choice of programming language, as opposed to those who use more lightweight languages. Those of us who use both types of language think the whole dichotomy is pure bull crap. Never were truer words ever spoken(or typed rather). |
Author: | klopyrev [ Sun Mar 25, 2007 5:47 pm ] | ||||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||||
heh... Java Method:
C++ Method:
So similar!!! KL |
Author: | haskell [ Sun Mar 25, 2007 5:56 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
In C++ you should use endl not \n to end your lines with a newline. Just throwing it out there. |
Author: | klopyrev [ Sun Mar 25, 2007 6:28 pm ] |
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge |
Yeah, I know! And for Java, I should use println. Just wanted to point out how similar they are, because Java doesn't have endl and C++ doesn't have println. |
Author: | wtd [ Sun Mar 25, 2007 11:34 pm ] | ||||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||||
PaulButler @ Mon Mar 26, 2007 12:23 am wrote:
O'Caml with recursion instead of imperative syntax - still wondering if this could be more O'Camlized. As with your previous program, very nice.
|
Author: | zylum [ Mon Mar 26, 2007 1:18 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | OneOffDriveByPoster [ Mon Mar 26, 2007 11:54 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
Trying something new (for me)--please tell me if you spot anything wrong or have any suggestions:
EDIT: code changed from previous version |
Author: | haskell [ Tue Mar 27, 2007 7:41 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
Haskell
|
Author: | rizzix [ Thu Mar 29, 2007 10:34 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | haskell [ Thu Mar 29, 2007 11:57 am ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
Quote: Not in scope: `>++'
Using GHC Interactive, version 6.6 for Haskell 98. This is because the forum syntax highlighter added the ">" on the string operation in this case. Which is an odd error. |
Author: | haskell [ Thu Mar 29, 2007 3:52 pm ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | BenLi [ Thu Mar 29, 2007 6:32 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
somebody please do this in an esoteric programming language |
Author: | haskell [ Thu Mar 29, 2007 8:43 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I'm working a a BF solution. So, I guess you can wait on that one lol. |
Author: | haskell [ Thu Mar 29, 2007 9:40 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | tw1st [ Tue Apr 03, 2007 10:09 am ] | ||
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge | ||
Disclaimer: While this example is for the most part the same as md's, it employs 'good' programming techniques, at least in Pascal where a begin and an end is necessary when there is more than one operation. Yes, I realize that it is not necessary in this example, but if the purpose of this is to show how other languages work, then this would be a good thing to show.
|
Author: | md [ Tue Apr 03, 2007 10:58 am ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I disagree. Using begin and end where there is no need just makes things larger and harder to read. I would say that my version is better ![]() |
Author: | wtd [ Tue Apr 03, 2007 12:55 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
Even md used an unnecessary begin and end. But on the whole, his version is better. |
Author: | zylum [ Thu Apr 05, 2007 3:07 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
|
Author: | md [ Thu Apr 05, 2007 3:57 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
/me hits zylum with an entire friggin forrest. WHY?! Good god man! won't you think of the children! |
Author: | zylum [ Fri Apr 06, 2007 11:07 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
![]() eidt: damnit! why don't the syntax tags support syntax highlighting for bf? |
Author: | klopyrev [ Sat Apr 07, 2007 2:50 pm ] |
Post subject: | Re: Fizz-Buzz: The Multi-Language Challenge |
Wow... zylum... I'm amazed that works. How the hell did you manage to do that? I couldn't even figure out how to read a number in. KL |
Author: | PaulButler [ Tue Jul 10, 2007 4:16 pm ] | ||||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||||
I can't beat bf, but here are a couple more languages: MzScheme (md already did scheme, but this is a bit different than his code) This is basically a scheme version of what I would write in any imperative language, I know it could be done in many ways and this is probably one of the worse ones.
And in Groovy Again, Groovy probably has some cool shortcuts I could have used, but I don't yet have the in-depth knowledge to know what those are.
|
Author: | Cervantes [ Tue Jul 10, 2007 5:20 pm ] | ||
Post subject: | Re: RE:Fizz-Buzz: The Multi-Language Challenge | ||
zylum @ Thu Apr 05, 2007 3:07 pm wrote:
I'm assuming whitespace is disregarded in bf and you did that on your own. I know you probably want the "z" to be for "zylum", but I first thought of "zoro". Sorry, but the picture of Zoro hacking computers is pretty awesome. |
Author: | wtd [ Tue Jul 10, 2007 5:31 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
It'd be hard to type with a sword. |
Author: | Martin [ Thu Jul 12, 2007 11:04 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
Lua!
Also, zylum, you are my hero. That is truly awesome. |
Author: | Aziz [ Thu Jul 12, 2007 1:27 pm ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
How about pseudo-code?
|
Author: | Martin [ Thu Jul 12, 2007 2:17 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
Careful, your algorithm has a bug in it. |
Author: | Aziz [ Thu Jul 12, 2007 2:59 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I see the bug. That first else isn't there. But then it screws up the rest of the logic so nvm it all. |
Author: | zylum [ Thu Jul 12, 2007 6:44 pm ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
your algorithm never outputs "FizzBuzz" |
Author: | Aziz [ Fri Jul 13, 2007 7:50 am ] |
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge |
I know. I thought I had something neat, but of course effed up a simpler part. |
Author: | Martin [ Fri Jul 13, 2007 8:35 am ] |
Post subject: | Re: RE:Fizz-Buzz: The Multi-Language Challenge |
Aziz @ Fri 13 Jul, 21:50 wrote: I know. I thought I had something neat, but of course effed up a simpler part.
No excuses, fix it ![]() |
Author: | Aziz [ Fri Jul 13, 2007 8:42 am ] | ||
Post subject: | RE:Fizz-Buzz: The Multi-Language Challenge | ||
fine
Though number modulo 3 should be stored in a variable for effeciency, this is the logic |