Skip to content

Commit 0414c9c

Browse files
authored
Merge pull request #3 from bestgopher/feature/new-script
Feature/new script
2 parents 265ac9c + 5558149 commit 0414c9c

35 files changed

+708
-1127
lines changed

Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ git2 = "0.13.15"
1111
reqwest = { version = "0.10", features = ["blocking", "json"] }
1212
serde_json = "1.0"
1313
serde = { version = "1.0", features = ["derive"] }
14+
clap = "3.0.0-beta.2"
15+
tera = "1.12.1"
16+
lazy_static = "1.4.0"
17+
regex = "1"
18+
1419

1520
[[bin]]
1621
name ="leetcode"
17-
path ="src/main.rs"
22+
path = "src/main.rs"

README.md

Lines changed: 251 additions & 739 deletions
Large diffs are not rendered by default.

src/all.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
use crate::file;
2+
3+
use std::sync::{Arc, Mutex};
4+
use std::thread;
5+
use crate::http::Resp;
6+
7+
8+
/// 重新格式化
9+
pub fn all() {
10+
let files = file::get_all_bin_file();
11+
12+
let v = Vec::<Resp>::with_capacity(files.len());
13+
14+
let x = Arc::new(Mutex::new(v));
15+
let mut handlers = vec![];
16+
17+
for i in 0..=files.len() / 10 {
18+
// 把files分块,分成10个文件一块
19+
let files = if i * 10 + 10 > files.len() {
20+
files[i * 10..files.len()].to_vec()
21+
} else {
22+
files[i * 10..i * 10 + 10].to_vec()
23+
};
24+
25+
let x = x.clone();
26+
27+
handlers.push(thread::spawn(move || {
28+
for i in files {
29+
println!("{} downloading", i);
30+
let resp = crate::http::get_question_info(&i);
31+
x.lock().unwrap().push(resp);
32+
}
33+
}))
34+
}
35+
36+
for i in handlers {
37+
i.join().unwrap();
38+
}
39+
40+
crate::file::write_readme(&mut *x.lock().unwrap());
41+
}

src/bin/boats-to-save-people.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Solution {
4444
count
4545
}
4646

47-
pub fn num_rescue_boats(mut people: Vec<i32>, limit: i32) -> i32 {
47+
pub fn num_rescue_boats(people: Vec<i32>, limit: i32) -> i32 {
4848
let mut v = vec![0; (limit + 1) as usize];
4949

5050
for i in people {

src/bin/climbing-stairs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::ptr::hash;
1+
22

33
fn main() {}
44

@@ -12,7 +12,7 @@ impl Solution {
1212

1313
let (mut a, mut b) = (1, 2);
1414

15-
for i in 3..=n {
15+
for _i in 3..=n {
1616
let a1 = a;
1717
a = b;
1818
b = a1 + b;

src/bin/combination-sum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Solution {
2222
v.push(i);
2323
r.push(v);
2424
} else if i < target {
25-
let mut x = Self::calc(&candidates, target - i);
25+
let x = Self::calc(&candidates, target - i);
2626
for mut m in x {
2727
if !m.is_empty() {
2828
if i >= *m.last().unwrap() {

src/bin/construct-binary-search-tree-from-preorder-traversal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl TreeNode {
2323
}
2424

2525
use std::cell::RefCell;
26-
use std::ops::Deref;
26+
2727
use std::rc::Rc;
2828

2929
struct Solution;

src/bin/count-complete-tree-nodes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ impl TreeNode {
2121
}
2222
}
2323

24-
use std::arch::x86_64::_mm_xor_pd;
24+
2525
use std::cell::RefCell;
26-
use std::cmp::{max, min};
26+
2727
use std::rc::Rc;
2828

2929
impl Solution {
@@ -70,7 +70,7 @@ impl Solution {
7070
}
7171

7272
while max_count - min_count > 1 {
73-
let mut middle = (min_count + max_count) / 2;
73+
let middle = (min_count + max_count) / 2;
7474

7575
let e = exists(root.as_ref(), middle, level);
7676
if e {

src/bin/fei-bo-na-qi-shu-lie-lcof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ impl Solution {
88
return n;
99
}
1010
let (mut last, mut result) = (1, 1);
11-
for i in 2..n {
11+
for _i in 2..n {
1212
let result1 = result + last;
1313
last = result;
1414
result = result1 % 1000000007;

src/bin/find-k-closest-elements.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl Solution {
2727
}
2828

2929
let index = Self::split(&arr, x);
30-
let (mut start, mut end, mut k) = (index, index, k as usize);
30+
let (mut start, mut end, k) = (index, index, k as usize);
3131
while end - start < k - 1 {
3232
if start == 0 {
3333
end += 1;

0 commit comments

Comments
 (0)