Codevita - Typical mistakes people make and how to correct them
Hello friends!!!
In this post, we will deal with primarily three kinds of errors which are a source frustration to many.
Compile Time Error:- Why isn't my program compiling on the Server?
Runtime Error:- What Wrong did my program do?
Wrong Answer:- How can my answer be wrong?
Question that gets asked the most, typically by first time users is - Code compiles fine on my machine. Why does the system say Compile Time Error?
Before diving deeper, ask yourself these questions
1) Am I using the same compiler as the server-side?
2) Is my IDE adding any switches to the compilation option? Do I know all the switches my IDE is using? Are they matching the server-side switches. The Server-side switches are
C :- gcc -Wall -lm $file
C++ :- g++ -Wall -lm $file
Java :- javac -J-Xms8m -J-Xmx8m -Xlint:none -XDsuppressNotes $file
Csharp :- mcs -warn:0 $file
CodeVita system requires that the compiler "run quiet". Upon successful compilation the compilation silently returns to the prompt without printing anything on the command prompt. This is the behaviour that you as a developer should target when you compile your programs. CodeVita system employs very lenient compilation options. You on your part should ensure that your code does not force the compiler to print Warnings or even Notes. To help you enforce this behaviour we have shared the switches that the CodeVita systems use for compiled languages.
If you use these switches, your probability of NOT receiving a compilation error increases dramatically for a valid code. Beyond this point really there are only edge cases. Some of them are outlined below
1) You may be using character set in your IDE that is not understood by the server. For e.g. copyright symbol in comments of your code.
2) You may be using characters which are acceptable on other platforms, but not on Linux such as '\b' for backspace. For e.g. printing a backspace using printf("\b") may work on Windows, but not on Linux.
Next, lets turn to Runtime Error
Let me tell you upfront that exposing Runtime Errors are a big Security Threat. It is for this reason that no information is provided regarding this error. Lets see some examples of Runtime Errors
1) Anything that is generally illegal will be reported as Runtime error for e.g reading array index beyond array size, accessing illegal memory location, Null Pointer exceptions, Cast Exceptions. You get the idea
2) Inadvertently, if your code converts into an infinite loop for some testcase(s) and you are printing inside that loop, then it will result in Runtime Error.
3) Making system calls from code is discouraged. If submitted code is malicious, server may take corrective action resulting in Runtime error. You are warned not to submit malicious code that can potentially be damaging to the platform.
Finally, we come to Wrong Answer phenomenon
Remember, in a previous post I told you that you are dealing with a machine behind the scenes. So if you make silly mistakes like appending text to the output for e.g. "Output is <SomeValue>" where the system only expects that <SomeValue> to be printed, the system will mark your answer as wrong. So even though your program outputs the correct answer (<SomeValue> in this case), because of not adhering to output specifications, you will receive a Wrong Answer as the status message.
Also, programs are thoroughly well-tested. Being bigoted about your answer being correct is immature. If the system gives you a message "Wrong Answer" then it is highly likely that your program is failing some test case. In the past 2 seasons of CodeVita where 80+ problems have been asked, there was only one instance where test case was wrong, due to human error at our end. So chances of your answer being right when the system is giving "Wrong Answer" as status message is ~1%.
I hope this saves you lot of frustrations and heart burn throughout the contest.
!!! All the Best !!!
!!! All the Best !!!
You can also like us at Facebook page also... www.facebook.com/tcspreparation
Comments
Post a Comment
Do you wanna ask me some thing???