blob: ab1fbd137c671acea33377aeccad0d45556aa271 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
use crate::structs::{StoneWall, GapHeights};
#[derive(Clone)]
struct State {
stones_used: Vec<bool>,
gaps: GapHeights,
}
impl State {
fn from_gaps(gaps: GapHeights, n: u32) -> Self {
let h = n/2 + 1;
Self {
stones_used: vec![false; n * h],
gaps
}
}
fn stone_used(&self, n: u32, h: u32) -> bool {
self.stones_used.get()
}
fn as_wall(&self, n: u32) -> StoneWall {
self.gaps.as_stone_wall(n)
}
}
struct RecursiveSolver {
n: u32,
states: Vec<GapHeights>
}
impl Sover for RecursiveSolver {
fn new(n: u32) -> Self {
let w = (n/2 + 1) * (n - 1);
let gaps = GapHeights::create_empty(w);
Self {
n,
states: vec![State::from_gaps(gaps)]
}
}
fn solve(&mut self) -> Option<StoneWall> {
let w = self.w();
if let Some(state) = self.states.last() {
}
}
fn n(&self) -> u32 {
self.n
}
}
|