leetcode-cli
leetcode-cli copied to clipboard
leetcode test 5: panic
leetcode test 5
[INFO leetcode_cli::plugins::leetcode] Sending code to judge...
thread 'main' panicked at 'submit succcessfully, parse question_id to i32 failed: ParseIntError { kind: Empty }', src/cache/models.rs:318:34
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
and the 5 source file
class Solution {
public:
// 1. ä¸å¿ƒæ‰©å±•æ³•
tuple<int, int, int> expandPalindrome(string &s, int left, int right) {
int k = 0;
while (left >= 0 && right < s.size()) {
if (s[left] == s[right]) {
left--;
right++;
k++;
} else {
break;
}
}
return make_tuple(k, left, right);
}
string longestPalindrome(string s) {
if (s.size() == 0) return s;
int max_length = 1;
int l = 0, r = 0;
for (size_t i = 0; i < s.size(); i++) {
int k_o = 0, k_e = 0;
int l_o = 0, l_e = 0;
int r_o = 0, r_e = 0;
tie(k_e, l_e, r_e) = expandPalindrome(s, i - 1, i + 1);
tie(k_o, l_o, r_o) = expandPalindrome(s, i, i + 1);
if (k_e * 2 + 1 > max_length) {
max_length = k_e * 2 + 1;
l = l_e;
r = r_e;
}
if (k_o * 2 > max_length) {
max_length = k_o * 2;
l = l_o;
r = r_o;
}
}
return s.substr(l + 1, r);
}
};
Reproduct: wrong code and test, will cause this error.
It seems to be fixed in this fork.
Can you open a PR? It seems this commit https://github.com/clearloop/leetcode-cli/commit/090773dc8a2d6f99582fbda0b40f934a8089399e fix this problem
Sure, but it's not my fork though :)
I thought that I could open a pr from that repo, but it's obviously not the case. I can just copy those changes in my fork and create a pr, but IMO it'd be more fair if the original author would be credited. Hey @manank20, can you please create a pr with your changes? The issues section was disabled in your fork, unfortunately, couldn't write to you there.
If the author won't then I can do it, let's wait a couple of days.
I created a pr, pardon me if i did something wrong.
Hi, I don't see #95 merged, are there any issues? The bug still occurs
I have one local version, and the #95 was truely not merged, can @clearloop handle it at free time ?
I have one local version, and the #95 was truely not merged, can @clearloop handle it at free time ?
thx for the reminder! @wendajiang btw would you mind to be a collaborator of this repo? ( you can review/merge the PRs ) I'm quite busy these months that don't have enough time to work on this, really appreciate that you are caring about this project !
I have one local version, and the #95 was truely not merged, can @clearloop handle it at free time ?
thx for the reminder! @wendajiang btw would you mind to be a collaborator of this repo? ( you can review/merge the PRs ) I'm quite busy these months that don't have enough time to work on this, really appreciate that you are caring about this project !
My pleasure.
My pleasure.
Just sent the invitation
I find some time dig into this problem, and when execute leetcode exec 1
the result from leetcode.com is
2022-12-14T08:33:25Z DEBUG leetcode_cli::cache::models] VerifyResult {
state: "SUCCESS",
name: "Two Sum",
data_input: "[2,7,11,15]\n9\n[3,2,4]\n6\n[3,3]\n6",
result_type: Submit,
pretty_lang: "C++",
correct_answer: false,
code_answer: [],
code_output: [
"",
],
expected_output: [
"",
],
std_output: [
"",
],
status: VerifyStatus {
status_code: 10,
status_msg: "Accepted",
status_memory: "12.2 MB",
status_runtime: "18 ms",
runtime_error: "",
},
analyse: Analyse {
total_correct: Some(
Number(57),
),
total_testcases: Some(
Number(57),
),
runtime_percentile: Some(
Number(84.00789999999998),
),
memory_percentile: Some(
Number(7.604199999999999),
),
},
expected: Expected {
expected_code_answer: [],
},
error: CompileError {
full_compile_error: "",
},
submit: Submit {
question_id: "1",
last_testcase: "",
compare_result: "111111111111111111111111111111111111111111111111111111111",
},
}
But, when execute leetcode test 1
, the result from leetcode.com is
2022-12-14T08:28:30Z DEBUG leetcode_cli::cache::models] VerifyResult {
state: "SUCCESS",
name: "Two Sum",
data_input: "[2,7,11,15]\n9\n[3,2,4]\n6\n[3,3]\n6",
result_type: Test,
pretty_lang: "C++",
correct_answer: true,
code_answer: [
"[0,1]",
"[1,2]",
"[0,1]",
],
code_output: [],
expected_output: [],
std_output: [
"",
"",
"",
"",
],
status: VerifyStatus {
status_code: 10,
status_msg: "Accepted",
status_memory: "6.2 MB",
status_runtime: "5 ms",
runtime_error: "",
},
analyse: Analyse {
total_correct: Some(
Number(3),
),
total_testcases: Some(
Number(3),
),
runtime_percentile: None,
memory_percentile: None,
},
expected: Expected {
expected_code_answer: [
"[0,1]",
"[1,2]",
"[0,1]",
],
},
error: CompileError {
full_compile_error: "",
},
submit: Submit {
question_id: "",
last_testcase: "",
compare_result: "111",
},
}
So i think is strange judge test or submit command by submit.compare_result is empty or not, when the test subcommand return one error, jump to the submit branch to execute and the question_id is empty string is the true reason, however, #95 can not fix this, and look like it already merge into the master, so I close it and would fix this issue later.
#103 fix this