use crate::solver::{wall_stats, Solver, IteratorSolver}; use crate::structs::StoneWall; use crate::permutations::PermutationGenerator; #[derive(Debug)] pub struct GpuSolver { n: u32, h: u32, w: u32, permutations: Vec>, masks: Vec, } impl GpuSolver { fn solve_to_vec(&mut self) -> Vec { vec![] } } fn generate_permutations(n: u32) -> Vec> { crate::permutations::HeapsPermutations::permutations(n) } fn generate_masks(permutations: &[Vec]) -> Vec { let mut masks = Vec::with_capacity(permutations.len()); for p in permutations { let mut v = 0; let mut x = 0u64; for i in p.iter().take(p.len() - 1).map(|i| { v += i; v }) { x |= 1 << i } masks.push(x) } masks } impl Solver for GpuSolver { fn new(n: u32) -> Self { let (h, w) = wall_stats(n); let permutations = generate_permutations(n); let masks = generate_masks(&permutations); Self { n, h, w, permutations, masks, } } fn n(&self) -> u32 { self.n } fn h(&self) -> u32 { self.h } fn w(&self) -> u32 { self.w } } impl IteratorSolver for GpuSolver { type IntoIter = std::vec::IntoIter; fn solve(mut self) -> Self::IntoIter { self.solve_to_vec().into_iter() } }