summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/solvers.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/solvers.rs b/src/solvers.rs
index 9bf0ad6..7e17b38 100644
--- a/src/solvers.rs
+++ b/src/solvers.rs
@@ -74,6 +74,21 @@ impl<T: num::PrimInt> Solver<T> {
}
pub fn solve(&mut self) -> Wall {
- Wall::create_empty(self.w)
+ let wall = Wall::create_empty(self.w);
+ wall.heights
+ .iter()
+ .take(2)
+ .zip(0..1)
+ .for_each(|(x, i)| self.set_stone(*x as usize, i));
+ wall
+ }
+
+ fn set_stone(&mut self, row: usize, stone: u32) {
+ self.solve_stack[row] =
+ self.solve_stack[row] | T::from(1 << stone).expect("Stone placing index out of bounds");
+ }
+
+ fn get_stone(&self, row: usize, stone: u32) {
+ self.solve_stack[row] & T::from(1 << stone).expect("Requested stone index out of bounds");
}
}