From cf70869da0b4fdba94930a87af3a2e89d145e950 Mon Sep 17 00:00:00 2001 From: William Ball Date: Wed, 7 Jul 2021 15:42:51 -0400 Subject: [PATCH] fixed? --- fractal_dimension/circle_counting_new/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fractal_dimension/circle_counting_new/src/lib.rs b/fractal_dimension/circle_counting_new/src/lib.rs index eea6856..2452989 100644 --- a/fractal_dimension/circle_counting_new/src/lib.rs +++ b/fractal_dimension/circle_counting_new/src/lib.rs @@ -12,7 +12,7 @@ pub fn fractal_dimension( generations: usize ) -> Result { let mut totals = vec![root.len(); n]; - let mut current = vec![(root, std::usize::MAX)]; + let mut current = vec![(root, std::usize::MAX, false)]; let mut next = vec![]; let xs: Vec = (1..=n) @@ -23,7 +23,7 @@ pub fn fractal_dimension( loop { next.clear(); - for (tuple, previous_generator) in ¤t { + for (tuple, previous_generator, bad) in ¤t { for (i, generator) in generators.iter().enumerate() { if i != *previous_generator { let new_tuple = generator * tuple; @@ -41,15 +41,17 @@ pub fn fractal_dimension( } for (k, max) in xs.iter().enumerate() { if curvature <= max { - if k == n - 1 { - add = true; - } + add = true; totals[k] += 1; } } } if add { - next.push((new_tuple, i)); + next.push((new_tuple, i, false)); + } else { + if !bad { + next.push((new_tuple, i, true)); + } } } }