A simplistic attempt at a Leetcode like backend that assesses code submissions for challenges based on correctness, size of code (tokens) and byte size.
The supported languages are Python and Javascript.
If you have your environment already setup (ocaml, dune, opam ...)
- Build the project
dune build- Run it!
dune exec code_submission_scoring- Run with docker:
docker build -t code_submission_scoring
docker run -p 8080:8080 code_submission_scoring- Example input for Longest Increasing Subsequence challenge.
{
"participant": "Alice",
"language": "Python",
"challenge_name": "Longest Increasing Subsequence",
"code": "def longest_increasing_subsequence(arr):\n from itertools import combinations\n n = len(arr)\n max_length = 0\n for r in range(1, n + 1):\n for subseq in combinations(arr, r):\n if list(subseq) == sorted(subseq) and len(set(subseq)) == len(subseq):\n max_length = max(max_length, len(subseq))\n return max_length\n\nprint(longest_increasing_subsequence(eval(input())))",
"timestamp": 1705839060.0
}- example output:
{
"participant": "Alice",
"language": "Python",
"challenge_name": "Longest Increasing Subsequence",
"execution_time": "36.48 milliseconds",
"code_size": "406 bytes",
"token_count": "86 distinct elements in your code (keywords, operators, or identifiers)",
"output": "4",
"score": "66.55 points",
"message": "Your code executed successfully and returned the correct output. Great job!"
}