summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatrixaeria <upezu@student.kit.edu>2019-12-20 06:47:23 +0100
committernatrixaeria <upezu@student.kit.edu>2019-12-20 06:47:23 +0100
commitef2936f2390cb44af811daada625e7d9abf4486a (patch)
tree41fc15665b81efa509555f9a464a7d185024725c
parent4fa0425d237f0a55d9d3d08138f2a5854eb3130f (diff)
Add a `from_heights` function to `Wall`
-rw-r--r--src/main.rs3
-rw-r--r--src/solvers.rs5
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 3c8449c..ddcc7c8 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,8 @@
mod solvers;
fn main() {
- let mut solver = solvers::Solver::<u8>::new(4);
+ let mut solver = solvers::Solver::<u8>::new(2);
+
let wall = solver.solve();
wall.output(solver.n, solver.h);
}
diff --git a/src/solvers.rs b/src/solvers.rs
index 24b7e2c..669fb6e 100644
--- a/src/solvers.rs
+++ b/src/solvers.rs
@@ -3,6 +3,10 @@ pub struct Wall {
}
impl Wall {
+ pub fn from_heights(heights: Vec<u32>) -> Self {
+ Self { heights }
+ }
+
fn create_empty(w: u32) -> Self {
let heights = if w == 0 {
vec![]
@@ -14,7 +18,6 @@ impl Wall {
v.push(1);
v
};
- let heights = vec![0, 1, 0, 2, 1, 0, 2, 2, 1];
Self { heights }
}