Skip to content

Change 'submit' vs 'run code' response parsing conditional from judge_type to submission_id startswith 'runcode_' #61

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions autoload/leetcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,24 @@ def _check_result(submission_id):

# the keys differs between the result of testing the code and submitting it
# for submission judge_type is 'large', and for testing judge_type does not exist
if r.get('judge_type') == 'large':
result['answer'] = _split(r.get('code_output', ''))
result['expected_answer'] = _split(r.get('expected_output', ''))
result['stdout'] = _split(r.get('std_output', ''))
result['runtime_percentile'] = r.get('runtime_percentile', '')
else:
# Note:
# As of October 09 2020, 'judge_type' is not provided in response,
# however we can use submission_id's value to decide output formatting
# 'Run code' Example submission_id: "runcode_1602277499.4352891_sYj3Jte5Lb"
# 'Submit' Example submission_id: "406680787"
if r.get('submission_id').startswith('runcode_'):
# Test states cannot distinguish accepted answers from wrong answers.
if result['state'] == 'Accepted':
result['state'] = 'Finished'
result['stdout'] = _split(r.get('code_output', []))
result['expected_answer'] = []
result['runtime_percentile'] = r.get('runtime_percentile', '')
result['expected_answer'] = r.get('expected_code_answer', [])
else:
result['answer'] = _split(r.get('code_output', ''))
result['expected_answer'] = _split(r.get('expected_output', ''))
result['stdout'] = _split(r.get('std_output', ''))
result['runtime_percentile'] = r.get('runtime_percentile', '')
return result


Expand Down