algorithmtimelanguage-agnosticsolver

Time only parts of programs of various languages


I am having a competition with a group of students where the goal is to solve N sudoku boards in the shortest amount of time. I am looking to automate the running and timing of programs by letting everyone upload their source code and a file saying how to build and run the program. My thought is that whenever someone uploads some code (in a language of their choice) and an instruction file, I spawn a container in which the program is compiled, run and timed. After the sudoku solving, the result should be a file with all boards solved so my script can verify that everything is indeed solved.

Now I have the following problem: I only want to time the execution of the solving algorithm, not the time it takes to read from and write to a file as that can vary from language to language. Timing the execution of the entire program would be no problem at all, but I am only interested in how quickly the algorithm solves the sudokus.

I cannot think of a good way to do this, so if anyone has a solution I would be grateful for any help I can get.


Solution

  • I agree with @Martheen. The student's program has to be written as a library that exports a single function of a known signature. You've written code that loads the student's library, then performs your tests for correctness, and times to test for speed. Always calling that single function with data already in RAM, then comparing against the known correct answer.

    You can translate your code into new target languages with an LLM.

    Yes, there are ways for students to try to break out of this sandbox. But winning entries will be studied, and cheats can be identified there and then. No need to be proactive about discovering it early.