Add blueprints directory and generalize benchmark and tests.
This commit is contained in:
parent
96a86779f4
commit
02e65f6fe3
12 changed files with 75 additions and 38 deletions
|
|
@ -629,23 +629,24 @@ impl Display for Bruteforce {
|
|||
mod test {
|
||||
use super::problems;
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
let mut b = problems::simple();
|
||||
macro_rules! test_bruteforce {
|
||||
($i:ident $x:expr) => {
|
||||
#[test]
|
||||
fn $i() {
|
||||
let mut b = problems::$i();
|
||||
|
||||
while b.next_finish_state() {}
|
||||
while b.next_finish_state() {}
|
||||
|
||||
assert_eq!(b.solution_count(), 9);
|
||||
assert_eq!(b.solution_count(), $x);
|
||||
}
|
||||
};
|
||||
($i:ident $x:expr; $($is:ident $xs:expr);+) => {
|
||||
test_bruteforce!($i $x);
|
||||
test_bruteforce!($($is $xs);+);
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn snake() {
|
||||
let mut b = problems::snake();
|
||||
|
||||
while b.next_finish_state() {}
|
||||
|
||||
assert_eq!(b.solution_count(), 5);
|
||||
}
|
||||
test_bruteforce!(simple 9; mid 238240; snake 5);
|
||||
}
|
||||
|
||||
pub mod problems {
|
||||
|
|
@ -669,6 +670,22 @@ pub mod problems {
|
|||
b.build()
|
||||
}
|
||||
|
||||
pub fn mid() -> Bruteforce {
|
||||
let mut b = BruteforceBuilder::new(6, 6);
|
||||
|
||||
b.add_path(
|
||||
(Position::new(0, 0), Direction::Down),
|
||||
(Position::new(5, 5), Direction::Down),
|
||||
);
|
||||
|
||||
b.add_path(
|
||||
(Position::new(0, 5), Direction::Up),
|
||||
(Position::new(5, 0), Direction::Up),
|
||||
);
|
||||
|
||||
b.build()
|
||||
}
|
||||
|
||||
pub fn snake() -> Bruteforce {
|
||||
let mut p = BruteforceBuilder::new(14, 3);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue