From 1f3d8d2d6fd18c68d76c0ed15d444432b7a214b0 Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 15:07:56 -0500 Subject: [PATCH 1/6] Added extra output to submission --- autoload/leetcode.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/autoload/leetcode.vim b/autoload/leetcode.vim index bf303c8..ac8d1ce 100644 --- a/autoload/leetcode.vim +++ b/autoload/leetcode.vim @@ -1000,7 +1000,8 @@ function! s:FormatResult(result_) abort endif call extend(output, s:FormatSection('Error', result['error'], 2)) - call extend(output, s:FormatSection('Standard Output', result['stdout'], 2)) + call extend(output, s:FormatSection('Output', result['stdout'], 2)) + call extend(output, s:FormatSection('Standard Output', result['code_output'], 2)) call extend(output, s:FormatSection('Input', result['testcase'], 3)) call extend(output, s:FormatSection('Actual Answer', result['answer'], 3)) From 47d4b38c655993c3f53b48447be6037f29372dd4 Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 15:16:32 -0500 Subject: [PATCH 2/6] Added extraction of code_output from the check result --- autoload/leetcode.py | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/leetcode.py b/autoload/leetcode.py index 436c595..3bc4147 100644 --- a/autoload/leetcode.py +++ b/autoload/leetcode.py @@ -338,6 +338,7 @@ def _check_result(submission_id): result = { 'answer': r.get('code_answer', []), + 'code_output': r.get('code_output'), 'runtime': r['status_runtime'], 'state': _status_to_name(r['status_code']), 'testcase': _split(r.get('input', r.get('last_testcase', ''))), From 3431fe28e2c76e8a84646f4307f39d96d6dba689 Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 15:47:35 -0500 Subject: [PATCH 3/6] Revert "Added extraction of code_output from the check result" This reverts commit 47d4b38c655993c3f53b48447be6037f29372dd4. --- autoload/leetcode.py | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/leetcode.py b/autoload/leetcode.py index 3bc4147..436c595 100644 --- a/autoload/leetcode.py +++ b/autoload/leetcode.py @@ -338,7 +338,6 @@ def _check_result(submission_id): result = { 'answer': r.get('code_answer', []), - 'code_output': r.get('code_output'), 'runtime': r['status_runtime'], 'state': _status_to_name(r['status_code']), 'testcase': _split(r.get('input', r.get('last_testcase', ''))), From 7a444c455f5d5e821faedffa8cc1eccb31eebb85 Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 15:47:53 -0500 Subject: [PATCH 4/6] Revert "Added extra output to submission" This reverts commit 1f3d8d2d6fd18c68d76c0ed15d444432b7a214b0. --- autoload/leetcode.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autoload/leetcode.vim b/autoload/leetcode.vim index ac8d1ce..bf303c8 100644 --- a/autoload/leetcode.vim +++ b/autoload/leetcode.vim @@ -1000,8 +1000,7 @@ function! s:FormatResult(result_) abort endif call extend(output, s:FormatSection('Error', result['error'], 2)) - call extend(output, s:FormatSection('Output', result['stdout'], 2)) - call extend(output, s:FormatSection('Standard Output', result['code_output'], 2)) + call extend(output, s:FormatSection('Standard Output', result['stdout'], 2)) call extend(output, s:FormatSection('Input', result['testcase'], 3)) call extend(output, s:FormatSection('Actual Answer', result['answer'], 3)) From 8f584ca922ebb70d6369173114e2c12e31b1572c Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 16:00:22 -0500 Subject: [PATCH 5/6] Forcing to use judge_type of large --- autoload/leetcode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/leetcode.py b/autoload/leetcode.py index 436c595..3fa4e11 100644 --- a/autoload/leetcode.py +++ b/autoload/leetcode.py @@ -348,7 +348,7 @@ 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': + 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', '')) From 3863a5ec3e27cfbb47984fcac2331ffda2f52570 Mon Sep 17 00:00:00 2001 From: Galus Date: Fri, 9 Oct 2020 16:13:44 -0500 Subject: [PATCH 6/6] Updated logic for determining if results are from a submission or a run code test --- autoload/leetcode.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/autoload/leetcode.py b/autoload/leetcode.py index 3fa4e11..04720d9 100644 --- a/autoload/leetcode.py +++ b/autoload/leetcode.py @@ -348,12 +348,12 @@ 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' @@ -361,6 +361,11 @@ def _check_result(submission_id): 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