Skip to content

Commit 32fd0a6

Browse files
committed
fix incorrect failure of testcase
1 parent 9ac39e4 commit 32fd0a6

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

src/handlers/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl std::fmt::Display for Success {
132132
);
133133
let mut part2 = Vec::with_capacity(self.code_answer.len());
134134
for i in 0..self.code_answer.len() {
135-
let is_correct = self.code_answer[i] == self.expected_code_answer[i];
135+
let is_correct = self.compare_result.chars().nth(i).unwrap_or('0') == '1';
136136
part2.push(format!(
137137
"{1}\n{2}\n{3}\n{0:10}: {4:?}\n{7:10}: {5:?}\n\n{6}",
138138
"Output",

src/handlers/leetcode.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,35 @@ impl LeetCode<Unauthorized> {
3232
let Some(csrf_token) = cookie
3333
.split(';')
3434
.find(|s| s.contains("csrftoken"))
35-
else{return Err("No csrf token found"); };
36-
let Some(csrf_token) = csrf_token.split('=').last() else{return Err("No csrf token found"); };
37-
let csrf_token = csrf_token.to_string();
38-
headers.insert(
39-
reqwest::header::COOKIE,
40-
reqwest::header::HeaderValue::from_str(&cookie).unwrap(),
41-
);
42-
headers.insert(
35+
else {
36+
return Err("No csrf token found");
37+
};
38+
let Some(csrf_token) = csrf_token.split('=').last() else{return Err("No csrf token found"); };
39+
let csrf_token = csrf_token.to_string();
40+
headers.insert(
41+
reqwest::header::COOKIE,
42+
reqwest::header::HeaderValue::from_str(&cookie).unwrap(),
43+
);
44+
headers.insert(
4345
reqwest::header::USER_AGENT,
4446
reqwest::header::HeaderValue::from_str("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36").unwrap(),
45-
);
46-
headers.insert(
47-
reqwest::header::REFERER,
48-
reqwest::header::HeaderValue::from_str("https://leetcode.com/").unwrap(),
49-
);
50-
headers.insert(
51-
reqwest::header::HeaderName::from_static("x-csrftoken"),
52-
reqwest::header::HeaderValue::from_str(csrf_token.as_str()).unwrap(),
53-
);
54-
let client = reqwest::blocking::Client::builder()
55-
.default_headers(headers.clone())
56-
.build()
57-
.unwrap();
58-
Ok(LeetCode {
59-
state: std::marker::PhantomData::<Authorized>,
60-
client,
61-
})
47+
);
48+
headers.insert(
49+
reqwest::header::REFERER,
50+
reqwest::header::HeaderValue::from_str("https://leetcode.com/").unwrap(),
51+
);
52+
headers.insert(
53+
reqwest::header::HeaderName::from_static("x-csrftoken"),
54+
reqwest::header::HeaderValue::from_str(csrf_token.as_str()).unwrap(),
55+
);
56+
let client = reqwest::blocking::Client::builder()
57+
.default_headers(headers.clone())
58+
.build()
59+
.unwrap();
60+
Ok(LeetCode {
61+
state: std::marker::PhantomData::<Authorized>,
62+
client,
63+
})
6264
}
6365
}
6466

src/handlers/leetcode/api/execute.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl LeetCode<Authorized> {
8080
match curr_state {
8181
PendingState::Pending => {
8282
if last_state != PendingState::Pending {
83-
println!("Status : Evalutaion Pending");
83+
println!("Status : Evaluation Pending");
8484
}
8585
}
8686
PendingState::Started => {

src/handlers/leetcode/api/question.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ impl LeetCode<Authorized> {
5959
let Ok(data) = client.post(url).json(&query).send() else {
6060
return Err("Failed to fetch question id from leetcode!");
6161
};
62+
6263
#[derive(Deserialize)]
6364
struct QuestionWrapper {
6465
question: LeetcodeQuestion,
6566
}
66-
6767
#[derive(Deserialize)]
6868
struct Data {
6969
data: QuestionWrapper,
@@ -80,7 +80,8 @@ impl LeetCode<Authorized> {
8080
query: query.to_string(),
8181
variables: varibales,
8282
})
83-
.send() else {
83+
.send()
84+
else {
8485
return Err("Failed to fetch boiler plate code!");
8586
};
8687

0 commit comments

Comments
 (0)