Computer Science Canada Quick contest (all languages) |
Author: | md [ Mon Oct 24, 2005 11:10 pm ] |
Post subject: | Quick contest (all languages) |
Ok... so I gave the challenge on IRC, but I figure I'll open it to anyone on compsci The Challenge: write a function to check to see if a string is a palendrome. It should only one parameter, the string, and return a boolean value of true if the string is a palendrome, or false if it is not. [edit] You can optionally also pass a second parameter to specify the length of the string, just to reduce the overhead of recursion... The Judges: I'll judge who wins by who can write the shortest code (instruction wise), who can write the fastest code (order n wise), and who's code is easiest to read. I might get a few other people (wtd, rizzix) to help judge too if I can. The prize: the proze will be all my bits devided amongst the winners, or if there is a mod who will sponsor this however much they feel like giving. |
Author: | [Gandalf] [ Mon Oct 24, 2005 11:15 pm ] | ||
Post subject: | |||
|
Author: | md [ Mon Oct 24, 2005 11:18 pm ] | ||
Post subject: | |||
My C/C++ entry so people have an idea how one could do it
|
Author: | beard0 [ Mon Oct 24, 2005 11:20 pm ] | ||
Post subject: | |||
Beat this :)
Hooray for Turing short circuit logic evaluation! |
Author: | beard0 [ Mon Oct 24, 2005 11:29 pm ] |
Post subject: | |
By the way Cornflake's "idea how one could do it" doesn't actually work, you need to expand on it. |
Author: | md [ Mon Oct 24, 2005 11:31 pm ] |
Post subject: | |
Yes, yes... so my mind was a little slow after my exam... it's changed and it does now work, I've tested it. [edit] arg... it's harder then it seems to write it on one line... see my sig [edit 2] my god I'm dumb... but it now works... tested verilly... |
Author: | wtd [ Tue Oct 25, 2005 12:14 am ] | ||
Post subject: | |||
O'Caml:
|
Author: | Martin [ Tue Oct 25, 2005 12:18 am ] | ||
Post subject: | |||
For an added challenge: Do it as a one liner recursive call to main in C, returning a number other than 0 if argv[0] is a palindrome, 0 if it isn't.
|
Author: | wtd [ Tue Oct 25, 2005 12:42 am ] | ||
Post subject: | |||
Martin wrote: For an added challenge:
Do it as a one liner recursive call to main in C, returning a number other than 0 if argv[0] is a palindrome, 0 if it isn't.
Did you actually mean argv[0]? That's typically the executable name. |
Author: | Martin [ Tue Oct 25, 2005 1:15 am ] |
Post subject: | |
Sorry, yeah, I forgot about that. It's been a while since I've used C. argv[1]; |
Author: | TokenHerbz [ Tue Oct 25, 2005 2:02 am ] |
Post subject: | |
To: Cornflake you said you'd gimmy 5 bits on IRC for trying When can i expect them? |
Author: | wtd [ Tue Oct 25, 2005 3:10 am ] | ||
Post subject: | |||
Ruby:
|
Author: | Tony [ Tue Oct 25, 2005 7:41 am ] | ||
Post subject: | |||
|
Author: | md [ Wed Oct 26, 2005 10:51 am ] |
Post subject: | |
Methinks I'll leave this open until next weekend and then I'll judge winners... and martin; I've almost figured out how to beat your challenge |
Author: | goomba [ Wed Oct 26, 2005 5:56 pm ] | ||
Post subject: | |||
Python for the win!
|
Author: | Hikaru79 [ Fri Oct 28, 2005 10:00 pm ] | ||||
Post subject: | |||||
goomba wrote: Python for the win!
Drat!! I was just about to post that. Just for the record, you can make this a one-liner:
|
Author: | goomba [ Fri Oct 28, 2005 10:03 pm ] |
Post subject: | |
Ooh... that's true. |
Author: | rizzix [ Fri Oct 28, 2005 10:31 pm ] | ||
Post subject: | |||
pwned? |
Author: | wtd [ Fri Oct 28, 2005 10:50 pm ] |
Post subject: | |
Why bother with the explicit type signature? |
Author: | rizzix [ Fri Oct 28, 2005 11:09 pm ] | ||
Post subject: | |||
true true... fixed... eitherway do you know a good one-liner? here's the best i could come up with:
|
Author: | goomba [ Sat Oct 29, 2005 1:22 pm ] | ||||||
Post subject: | |||||||
Hikaru79 wrote: goomba wrote: Python for the win!
Drat!! I was just about to post that. Just for the record, you can make this a one-liner:
Going even further, how about a real one-liner:
There we go. |
Author: | md [ Sun Oct 30, 2005 1:57 pm ] | ||||||||||||||||||||||
Post subject: | |||||||||||||||||||||||
Weekend -> Contest is over. However I'm lazy and have lots of study to do so methinks I'll leave hte judging until later... (if at all). There are some interesting solutions, though the one line solutions are only one line because all the work is being done by the language and other routines (ei. because they cheat ). I did leave it open to all languages however so I suppose I can't complain. And so no one can cheat... here are all the entries... Gandalf:
beard0:
wtd:
Tony:
Goomba:
Hiraku79:
rizzix:
Cornflake:
|