I have 15+ years’ experience programming in dozens of languages
I have spent ~4 hours searching Google and the Codechef forums for a solution. Please don’t respond with “read the manual”
As far as I can tell, Codechef is broken when submitting PHP code for any output that’s more than one line long.
Although the system DOES work for a single line of output, as demonstrated by http://www.codechef.com/wiki/sample-solutions#PHP, anything beyond that returns either “NZEC” or “Wrong Answer” for EVERY possible combination of input and output methods, for EVERY problem I’ve tried, even though ALL of my solutions work on my local machine.
Same as above, but being careful not to include a \n after the final line of output
So CodeChef guys, if their actually is a way to use PHP to solve challenges on your site, please post a substantial challenge (multiple lines of input, multiple lines of output) solved in PHP.
Otherwise, do the world a favor and disable PHP on your site. You’re wasting thousands of hours of people’s time every month by posting challenges that are, literally, impossible to get right.
It looks like this might go deeper than just plugging into Codechef’s IO system. I suspect there might be something interesting going on with how the solutions are tested against the problem author’s answer files …perhaps Unix vs Windows EOL characters.
I should have given up on this hours ago, but I’m gong to try some other things and report back.
This is just too time consuming to debug because I can’t see either the test cases or the output from the interpreter. Its literally a black box.
If you want to practice coding in PHP, use this site:
Really good problems, and its so much easier to work with, because you can see the output from your code side-by-side with the input that was sent to your code by the test system (just click on any errors in the results list)
@foxly Codechef uses the same SPOJ judge to judge its solutions. errors displayed are also almost same. You can view details about codechef errors here : http://www.codechef.com/wiki/faq
Is there a specific reason why CodeChef can’t display something along the lines of:
TEST FAILED
= = = = = = = = =
Input: AAAA
Expected Output: “XXXX”
Your Output: “YYYY”
…when a user’s code fails?
I can understand why you might want to keep the tests “secret” during competitions, but if the goal of CodeChef is to help people build their programming skills, they’d learn an awful lot faster if they had meaningful debugging info.
@foxly: That is a harsh criticism that you have made. We believe that there is no issue with the way we execute PHP on our program checker machine. However we may be wrong. Let me explain. As mentioned by @kcahdog we use the same judge that SPOJ use for checking out the programs. All the standard PHP I/O functions are supported in our PHP environment without any errors. Also from the I/O examples that you have mentioned above all of them should work without producing any error, well except #1, which has error in the code.
Please don’t associate Wrong Answer or Run Time Exception(NZEC) with broken PHP environment on CodeChef unless we can nail it down. We agree that there should be better sample solutions and our FAQ page may be improved to better cater to new users. However, there is only so much that we can do.But, since our FAQ page is a wiki page, we also expect the community to help us improve it. Since you have spent so much time on this issue, it will be great help to the community if you can devote a few more minutes in documenting this in the FAQ. In case you face any issues in doing so, please let us know.
@php_shailesh: Your submission is not meeting the memory limits for this problem and hence the judge needs to kill the running of the submission. You need to optimize your implementation to use less memory. Please refer to the editorial of this problem to get better ideas.