summaryrefslogtreecommitdiff
path: root/src/solvers/mod.rs
blob: 0615eabd76a3f0366db5c0977f2f5c437274d65d (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
//pub mod incremental_block;
pub mod intuitive;
#[cfg(feature = "gpu")]
pub mod opencl;

lazy_static! {
    pub static ref PERMUTATIONS: (Vec<Vec<u32>>, Vec<u64>) = {
        let n = crate::N;
        let mut heap = (1..=n).collect::<Vec<u32>>();
        let heap = permutohedron::Heap::new(&mut heap);
        let n_f = permutohedron::factorial(n as usize);
        let mut permutations = Vec::with_capacity(n_f);

        let mut masks: Vec<u64> = vec![0; n_f];
        println!("Generating permutations");
        for (j, data) in heap.enumerate() {
            let mut sum = 0;
            permutations.push(data.clone());
            for stone in data.iter().take(n as usize - 1) {
                sum += stone;
                masks[j] |= 1 << sum;
            }
        }
        (permutations, masks)
    };
}