summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/solvers/intuitive.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/solvers/intuitive.rs b/src/solvers/intuitive.rs
index f4deb8c..77f63e5 100644
--- a/src/solvers/intuitive.rs
+++ b/src/solvers/intuitive.rs
@@ -15,6 +15,8 @@ pub struct NormalSolver<T: num::PrimInt> {
// used during row creation, will get deprecated
static mut COUNT: u32 = 0;
+static mut TRIES: u32 = 0;
+static mut SOLUTIONS: u32 = 0;
/// Save the current state for each row
#[derive(Clone, Copy)]
@@ -94,6 +96,7 @@ impl<T: num::PrimInt> NormalSolver<T> {
0,
((0..self.h).collect::<Vec<u32>>()).as_ref(),
);
+ unsafe { println!("tries: {}\nsolutions: {}", TRIES, SOLUTIONS) }
}
fn permute(&mut self, up: usize, index: usize, numbers: &[u32]) {
@@ -115,10 +118,13 @@ impl<T: num::PrimInt> NormalSolver<T> {
}
fn check_perm(&mut self, nums: &[u32]) -> bool {
+ unsafe {
+ TRIES += 1;
+ }
let mut sums = vec![self.w; self.w as usize];
for (i, num) in nums.iter().enumerate() {
let mut sum = 0;
- for n in self.permutations[*num as usize][..=self.h as usize].iter() {
+ for n in self.permutations[*num as usize][..(self.n - 1) as usize].iter() {
sum += *n as usize;
if sums[sum - 1] != self.w {
return false;
@@ -126,6 +132,9 @@ impl<T: num::PrimInt> NormalSolver<T> {
sums[sum - 1] = i as u32;
}
}
+ unsafe {
+ SOLUTIONS += 1;
+ }
//println!("{:?}", sums);
GapHeights::from_heights(sums.iter().map(|x| *x as u32).collect()).output(self.n, self.h);
//.as_stone_wall(self.n)