admin管理员组

文章数量:1315344

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.

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.

Share Improve this question asked Jan 30 at 10:21 Henrik Hillestad LøvoldHenrik Hillestad Løvold 1,3015 gold badges22 silver badges50 bronze badges 3
  • 3 If the language choice can be constrained, I'd provide one interface for each language that consumes and returns purely on RAM. For JVM and .NET CLR, just one interface is needed to handle almost all kind of languages that support the runtime, ie, write the interface in Java, the student can choose Scala or Kotlin, with .NET the student can choose C#, F#, VB.NET etc. That said, it's not really language agnostic because non-trivial compilers might have different optimization/overhead on different languages – Martheen Commented Jan 30 at 10:32
  • 1 Just make sure that N is large enough for the read/write to file to be negligible if done correctly. – m.raynal Commented Jan 30 at 10:38
  • 1 You may ask the students to include in the solutions the duration of the computation for each Sudoku. However, without checking the source code, you can't be sure that there is no cheat. – Graffito Commented Jan 30 at 11:49
Add a comment  | 

1 Answer 1

Reset to default 2

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.

本文标签: algorithmTime only parts of programs of various languagesStack Overflow