Though there is NO official blog available for this, still I tried to attach the resources from different sites.
1) When you click the "run" button on the website, an API request is sent to the back-end containing your code (along with other relevant information such as your user ID and the ID of the problem being solved).
2)When the server receives the request, several things happen. The server compiles your code (or tries to, if you're using a compiled language).
3) The server then executes the resulting program. I'm assuming it'll be run inside a container (e.g. Docker). This is due to a number of factors. First, the amount of memory and other resources available to your program can be precisely controlled.
๐๐๐๐จ๐ง๐, to precisely control the environment in which it runs; for example, Java programs, will launch a container from an image that only contains the bare minimum Java runtime and nothing else.
๐๐ก๐ข๐ซ๐, to make it simple to set a timeout, i.e. simply kill the container if it does not complete running within the time limit.
๐
๐จ๐ฎ๐ซ๐ญ๐ก, and most importantly, for security. Using a container makes it simple to ensure that the program does not interact with anything other than the standard I/O (stdin, stdout, stderr) used to test your program. For example, your program may be unable to access the network or filesystem because the container does not explicitly permit it.
Once your program's container (or, more likely, one container for each test case) is running, the data for that test case is sent to that container's STDIN. The system then reads the STDOUT and compares it to the expected output of the program. If there is an exact match, the test case passes. Otherwise, if there is no exact match, the test times out, or a runtime error occurs, then the test case fails.
4) The results of the test are saved and sent back to the user.
๐ ๐๐๐ ๐ช๐ฎ๐๐ฌ๐ญ๐ข๐จ๐ง ๐ ๐๐๐ฒ ๐ค๐๐๐ฉ๐ฌ ๐ญ๐ก๐ ๐๐ง๐ญ๐๐ซ๐ฏ๐ข๐๐ฐ ๐ ๐๐๐ซ ๐๐ฐ๐๐ฒ
Top comments (0)