Hi guys,
I know there are quite a lot such contests already, but this one I found to be really cool and enjoyable. Since I am a newbie, I can only manage a couple of the contest puzzles. But they are all really programming puzzles, not math tests!
If you are good, you can even win an iPad! The site is called CoderCharts (http://codercharts.com).
One thing I like especially is their source code editor ... really well-thought and user-friendly. Nice looking too.
I tried the first one, which is pretty trivial, but I've never written a program where main() accepts arguments.
Could someone give me a basic example?
Edit: I seem to have figured it out just by guessing, but an in depth explanation would still help.
Edit Again: @Kyon: The substitution table is one of the arguments. It won't always be "ZYXWVUT..."
When I try to verify for the Noob cipher I'm getting this:
ERROR(incorrect): Incorrect result
Your submission failed to give the exact answer on the verification test. Please verify your code.
For reference, you program generated these results:
WELCOME TO CODER CHARTS
Any ideas what could be wrong? I've checked for new line characters.
@chrisname and kyon: Why are you're codes so complicated? Mine is only 22 lines long (not including whitespace).
Edit: Okay, I got it. Apparently you're supposed to exit when you hit a newline character?
Edit number 2^64: Nevermind. It verified correctly but I still got the wrong answer.
I like the score by running time.
@Kyon: line 21if (c.Crypt[i]!=d[i]) out += c.Clear[i]; that condition makes no sense. (edit: And it is not out of bounds just because they are strings and there is an '\0' at the end)
I think that you could assume that the input is not corrupted.
My code is not complicated. It's just longer. ;) I also added some "checks" for if a character was lowercase instead of uppercase.(using to_up() and for_each) The rest is just writing to a file (which is checked for being open) and calling a function or two.
EDIT:
Ne, that isn't for corrupted output, that is for when the loop exits, since it can exit for a multitude of reasons. If it runs out of characters to check, you will have to add the same character to maintain validity. If it exited before going out of characters to check, you should add the character from the Clear string.
I do however admit that the if was a bit bloated.. Could just have done some > and >= with i.
I was doing another one..
Does this code work when you test it yourself?
By the way, 88 is 'X'. You're ignoring Y and Z.
To prevent such errors I suggest using quoted char instead of it's ASCII value. Would make the code more readable.
Speaking of which, I one saw a code where '!' , '+' and '5' were used as some offset constants that have nothing to do with the symbols themselves. It took a while before I understood that this wasn't supposed to make sense...