Posted: Sat Jun 21, 2008 12:29 pm Post subject: Multi-language golf contest!
This is a very simple contest I decided to run. I want to encourage skill and discussion in various programming languages. Anyway, the contest is: Write code, in one of the language categories solving one of the tasks given, in as few characters as possible. I will not be comparing languages against each; Each entry will only be compared against entries in the same language.
Language categories:
Java
C
C++
Turing
Python
Ruby
I've only thought up one task, but if you guys have any suggestions, I'll be glad to hear them.
The first task is: make a compact code entry character counter. It must be able to ignore comments in any of the entries, count newlines and carriage returns. Carriage returns should count as one character. Oh, and don't forget to skip over characters in a string. Oh, and \t characters count as one character.
Of course, the entries should work.
What do you win? Why, prestige of course. I'll also donate a bunch of bits... except I don't have many, lol. Probably learn stuff, and become a better programmer.
Here is my "naive" entry, which I believe works 100%. If your entry does not give the same result, it is disqualified. And for reference, using it on itself, gives a result of 910 characters.
compact.zip
Description:
Baseline entry for the first task. Used on itself gives a result of 910 characters.
Posted: Sat Jun 21, 2008 1:08 pm Post subject: RE:Multi-language golf contest!
Mods can sponsor bits.
However, I'm curious, why limit it to only those languages?
Zeroth
Posted: Sat Jun 21, 2008 1:12 pm Post subject: Re: Multi-language golf contest!
Well, because I knew the comment delimiting characters in those languages? Remember, the task of the compact character counter includes skipping over comments. If you have a language you'd like to try, suggest it.
rizzix
Posted: Sat Jun 21, 2008 1:20 pm Post subject: RE:Multi-language golf contest!
Perl, Haskell, Scala, O'Caml, Common Lisp, to name a few.
Zeroth
Posted: Sat Jun 21, 2008 1:38 pm Post subject: Re: Multi-language golf contest!
Umm, what are the comment delimiters for those languages?
rizzix
Posted: Sat Jun 21, 2008 1:47 pm Post subject: RE:Multi-language golf contest!
For Scala its the same as Java.
For Perl, its the same as Python, Ruby, etc.
For Haskell: --
For Lisp: ;
For O'Caml, well I don't know.
(I'm assuming by comments we're talking about line-comments only)
gitoxa
Posted: Sat Jun 21, 2008 9:33 pm Post subject: RE:Multi-language golf contest!
Quote:
which I believe works 100%. If your entry does not give the same result, it is disqualified
There's something wrong with those two sentences.
Not bashing your program at all; just your logic.
Zeroth
Posted: Sat Jun 21, 2008 10:01 pm Post subject: Re: Multi-language golf contest!
Well, its assumed if anyone finds a bug in my code, they'll point it out. You're disqualified. (Not really, just kidding)
Sponsor Sponsor
gitoxa
Posted: Sat Jun 21, 2008 10:17 pm Post subject: RE:Multi-language golf contest!
Haha, true enough. On to making my own, though. I'll probably do turing first, just to help me get my thoughts out easily with a familiar language, then give another one a try. Perhaps python, since I already have something to compare with after.
Oh, and are we supposed to somewhat follow standard coding conventions? Or are we just going for the lowest amount of characters... heh.
One other quick question, I don't completely understand what you mean about the strings. Is an entire string being counted as 1, are you ignoring the quotes, or does python do something weird with quotes when trying to get input?
yet another edit:
I noticed your program counts the line feeds at the end of comments as a character, for example, the following results 7.
code:
Hello #Hi
#Goodbye
is that on purpose?
And I may come up with some other questions shortly. I ran my program on your code and got a different number. ...A very different number.
Zeroth
Posted: Sat Jun 21, 2008 11:32 pm Post subject: Re: Multi-language golf contest!
That is on purpose. Because \n still counts as a character, that IS read by compilers/interpreters. Sometimes it has meaning, sometimes it doesn't. Comments however, are not read by compilers/interpreters. Good questions.
Zeroth
Posted: Sat Jun 21, 2008 11:33 pm Post subject: Re: Multi-language golf contest!
Don't forget to handle strings!
gitoxa
Posted: Sun Jun 22, 2008 1:37 am Post subject: RE:Multi-language golf contest!
after a lengthy google search, o'caml's comment is
(* Comments here *)
Zeroth
Posted: Sun Jun 22, 2008 8:55 pm Post subject: Re: Multi-language golf contest!
Okay, Gitoxa has his entries in:
For the languages I suggested, in Turing, his code comes in at 409 characters.
For all the languages, in Turing, his code comes in at 548 characters. Good job Gitoxa!
Saad
Posted: Sun Jun 22, 2008 8:58 pm Post subject: Re: Multi-language golf contest!
Will there be nested quotes, like "Foo \" nested Foobar \" Bar" ?
Edit: I also see your code supports pything, turing and ruby, but from the main post I am confused about what language (s) are supposed to be supported by our code.
Zeroth
Posted: Sun Jun 22, 2008 9:47 pm Post subject: Re: Multi-language golf contest!
The main qualities are the languages I stated in my main post. You can also support the languages rizzix suggested as well, for a separate category.