Fix bugs (switch naive and cyclic) and add timing output for series calculation
This commit is contained in:
parent
be3697a749
commit
46907f8752
3 changed files with 10 additions and 9 deletions
|
|
@ -2,7 +2,8 @@ fn main() {
|
|||
for length in 2.. {
|
||||
let mut count = 0;
|
||||
let mut state = vec![0, 1];
|
||||
let start = std::time::Instant::now();
|
||||
stamp_folding::cyclic::stamp_folding(&mut state, 1, length - 2, &mut count, &mut |_, _| {});
|
||||
println!("{length:02}: {count} {}", count * 2);
|
||||
println!("{length:02}: {count} {} {:?}", count * 2, start.elapsed());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub fn stamp_folding(
|
|||
// dbg!(¤t, depth, last_inserted_index);
|
||||
if remaining == 0 {
|
||||
callback(*count, current);
|
||||
*count = count.checked_add(1).unwrap();
|
||||
*count = count.checked_add(depth as u128).unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -37,12 +37,6 @@ pub fn stamp_folding(
|
|||
}
|
||||
}
|
||||
|
||||
if last.is_none() {
|
||||
current.insert(0, depth);
|
||||
stamp_folding(current, 0, remaining - 1, count, callback);
|
||||
current.remove(0);
|
||||
}
|
||||
|
||||
let mut last = None;
|
||||
for i in (last_inserted_index + 1)..current.len() {
|
||||
if let Some(l) = last {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub fn stamp_folding(
|
|||
// dbg!(¤t, depth, last_inserted_index);
|
||||
if remaining == 0 {
|
||||
callback(*count, current);
|
||||
*count = count.checked_add(depth as u128).unwrap();
|
||||
*count = count.checked_add(1).unwrap();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +37,12 @@ pub fn stamp_folding(
|
|||
}
|
||||
}
|
||||
|
||||
if last.is_none() {
|
||||
current.insert(0, depth);
|
||||
stamp_folding(current, 0, remaining - 1, count, callback);
|
||||
current.remove(0);
|
||||
}
|
||||
|
||||
let mut last = None;
|
||||
for i in (last_inserted_index + 1)..current.len() {
|
||||
if let Some(l) = last {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue