Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

PHP is BROKEN on CodeChef

$
0
0

1) I have 15+ years' experience programming in dozens of languages

2) 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.

The following strategies fail in all cases:

EXAMPLE 1:

$in = fopen(STDIN, "r"); $out = fopen('php://stdout',"w");

Then read from $in as

$line = trim(fgets($in, 4096));

And output it as:

fwrite($out, sprintf("%s\n", $result));

EXAMPLE 2:

$line = fgets(STDIN, 3);

Then output

echo($result);

EXAMPLE 3:

$line = fgets(STDIN, 3); $out = fopen('php://stdout',"w");

Then output

fwrite($out, sprintf("%s\n", $result));

EXAMPLE 4:

Same as above, but being careful not to include a \n after the final line of output

3) 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.


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>