ianding1 / leetcode.vim

Solve LeetCode problems in Vim!
MIT License
308 stars 43 forks source link

When submitting test, got error with empty function #35

Closed crokobit closed 4 years ago

crokobit commented 4 years ago

NVIM v0.3.8

reproduce procedure:

  1. open question 1, two sum question.
  2. submitting with blank function
  3. got error below.

or

  1. open question 1, two sum question.
  2. submitting with return [0,1]
  3. got error below.

But it shows no error with the right code.

The error is:

Error detected while processing function <SNR>120_CheckRunCodeTask[19]..<SNR>120_ShowRunResultInPreview[15]..<SNR>120_FormatResult[32]..<SNR>120_FormatSection:

line    4:
E714: List required
ianding1 commented 4 years ago

Hi,

I ran the procedure on my computer but didn't reproduce this error. I tried both in C++ and Python and found that they returned a list of strings.

Could you provide more information, such as the code that you used?


The Python code that I used for two sum:

class Solution(object):
    def twoSum(self, nums, target):
       print('1,2,3') 

And I got:

# Two Sum

## State
  - Finished

## Runtime
  - 32 ms

## Standard Output
    1,2,3

### Input
    [2,7,11,15]
    9

### Actual Answer
    []

### Expected Answer
    [0,1]
motephyr commented 4 years ago

Hi, @ianding1 On my side, I used javascript to submit to code.

var twoSum = function(nums, target) {
  return [0, 1];
};

The result output

{'passed': 4, 'runtime_percentile': v:null, 'answer': [], 'title': 'Two Sum', 'state': 'Wrong Answer', 'testcase': ['[3,2,4]', '6'], 'runtime': 'N/A', 'stdout': '[0,1]', 'total': 29, 'expected_answer': []
, 'error': []}

The stdout is a string, so if I call this:

    call extend(output, s:FormatSection('Standard Output', result['stdout'], 2))

It will show the error by @crokobit mentioned.

It seems because my return value is an array.

ianding1 commented 4 years ago

Please try updating to the latest version.

Related commit: b5c55f41299e511b0e4076b03215a0

motephyr commented 4 years ago

Fixed. Thank you

crokobit commented 4 years ago

Nice work @motephyr @ianding1 :) That's the opensource spirit. 🍻