minor optimizations fourthfree rust
This commit is contained in:
parent
a74ede0ac8
commit
23e9c95dbd
1 changed files with 5 additions and 11 deletions
|
|
@ -17,14 +17,11 @@ fn is_fourth_free(x: &u64) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn step(x: &u64) -> Vec<u64> {
|
fn step(x: &u64) -> Vec<u64> {
|
||||||
let mut new_xs: Vec<u64> = Vec::new();
|
(0..BASE)
|
||||||
for d in 0..BASE {
|
.into_iter()
|
||||||
let temp = x * BASE + d;
|
.map(|d| x * BASE + d)
|
||||||
if is_fourth_free(&temp) {
|
.filter(|d| is_fourth_free(d))
|
||||||
new_xs.push(temp);
|
.collect()
|
||||||
}
|
|
||||||
}
|
|
||||||
new_xs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next(ls: Vec<u64>) -> Vec<u64> {
|
fn next(ls: Vec<u64>) -> Vec<u64> {
|
||||||
|
|
@ -61,8 +58,5 @@ fn main() {
|
||||||
i += 1;
|
i += 1;
|
||||||
println!("{}\t{}", i, ls.len());
|
println!("{}\t{}", i, ls.len());
|
||||||
ls = next(ls);
|
ls = next(ls);
|
||||||
if i == 6 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue