optimizations
This commit is contained in:
parent
7343abffb2
commit
d1c85455e6
2 changed files with 6 additions and 4 deletions
|
|
@ -7,4 +7,4 @@ edition = "2018"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rug = "1.10.0"
|
rayon = "1.1"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
use rayon::prelude::*;
|
||||||
|
|
||||||
// use std::thread;
|
// use std::thread;
|
||||||
|
|
||||||
// const NUM_THREADS: usize = 12;
|
// const NUM_THREADS: usize = 12;
|
||||||
const BASE: u64 = 2;
|
const BASE: u64 = 10;
|
||||||
|
|
||||||
fn is_fourth_free(x: &u64) -> bool {
|
fn is_fourth_free(x: &u64) -> bool {
|
||||||
let mut i = 2;
|
let mut i = 2;
|
||||||
|
|
@ -25,7 +27,7 @@ fn step(x: &u64) -> Vec<u64> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next(ls: Vec<u64>) -> Vec<u64> {
|
fn next(ls: Vec<u64>) -> Vec<u64> {
|
||||||
ls.iter().map(step).flatten().collect()
|
ls.par_iter().map(step).flatten().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// fn next(ls: Vec<u64>) -> Vec<u64> {
|
// fn next(ls: Vec<u64>) -> Vec<u64> {
|
||||||
|
|
@ -62,7 +64,7 @@ fn main() {
|
||||||
loop {
|
loop {
|
||||||
i += 1;
|
i += 1;
|
||||||
val += ls.len() as f64 / 2u64.pow(i) as f64;
|
val += ls.len() as f64 / 2u64.pow(i) as f64;
|
||||||
ls = next(ls);
|
|
||||||
println!("{}\t{}\t{}", i, ls.len(), val);
|
println!("{}\t{}\t{}", i, ls.len(), val);
|
||||||
|
ls = next(ls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue