summaryrefslogtreecommitdiff
path: root/src/solvers/incremental_block.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/solvers/incremental_block.rs')
-rw-r--r--src/solvers/incremental_block.rs45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/solvers/incremental_block.rs b/src/solvers/incremental_block.rs
index d4ebb81..19f8f76 100644
--- a/src/solvers/incremental_block.rs
+++ b/src/solvers/incremental_block.rs
@@ -1,9 +1,11 @@
-use std::iter::repeat;
-use crate::solver::{Solver, wall_stats};
+use crate::solver::{wall_stats, Solver};
use crate::structs::StoneWall;
+use std::iter::repeat;
pub struct IncrementalBlockSover {
- n: u32, h: u32, w: u32,
+ n: u32,
+ h: u32,
+ w: u32,
rows: Vec<Vec<(u32, u32)>>,
}
@@ -34,12 +36,15 @@ impl<'s> SubSolver<'s> {
if row_existence.iter().all(|&x| x) {
Some(Self {
count: index,
- start, solver,
+ start,
+ solver,
heights: Vec::with_capacity(index as usize),
pos: vec![0; gap_possibilities.len()],
gap_possibilities,
})
- } else { None }
+ } else {
+ None
+ }
}
fn increment_at(&mut self, n: u32) -> bool {
@@ -60,9 +65,7 @@ impl<'s> Iterator for SubSolver<'s> {
type Item = ();
fn next(&mut self) -> Option<Self::Item> {
- for (i, p) in self.pos.iter().enumerate().rev() {
- t
- }
+ for (i, p) in self.pos.iter().enumerate().rev() {}
None
}
}
@@ -71,11 +74,11 @@ impl IncrementalBlockSover {
fn generate_first_row(&mut self) {
let mut sum = 0;
self.rows[0] = (1..=self.n)
- .map(|n| {
- sum += n;
- (sum - n, n)
- })
- .collect();
+ .map(|n| {
+ sum += n;
+ (sum - n, n)
+ })
+ .collect();
}
fn get_wall(&self) -> StoneWall {
@@ -89,15 +92,14 @@ impl IncrementalBlockSover {
}
fn visited(&self, row: u32, stone: u32) -> bool {
- self.rows[row as usize].iter()
+ self.rows[row as usize]
+ .iter()
.position(|&(_, s)| s == stone)
.is_some()
}
fn row_size(&self, row: u32) -> u32 {
- self.rows[row as usize]
- .last()
- .map_or(0, |&(i, s)| i + s)
+ self.rows[row as usize].last().map_or(0, |&(i, s)| i + s)
}
}
@@ -105,10 +107,12 @@ impl Solver for IncrementalBlockSover {
fn new(n: u32) -> Self {
let (h, w) = wall_stats(n);
Self {
- n, h, w,
+ n,
+ h,
+ w,
rows: repeat(Vec::with_capacity(h as usize))
- .take(h as usize)
- .collect()
+ .take(h as usize)
+ .collect(),
}
}
@@ -130,4 +134,3 @@ impl Solver for IncrementalBlockSover {
self.w
}
}
-