From: Ian Jackson Date: Sat, 29 Oct 2022 19:44:35 +0000 (+0100) Subject: settlings wip X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=0866bc1344258b7123301e2c0dd26e4326fb93ff;p=z3-treefoil settlings wip --- diff --git a/src/lib.rs b/src/lib.rs index 940312c..fe0b2ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,7 @@ pub use std::io; pub use std::io::Write as _; pub use std::iter; +pub use itertools::izip; pub use itertools::Itertools as _; pub fn default() -> T { Default::default() } @@ -37,6 +38,21 @@ pub fn shape_edges(shape: &Shape) -> impl Iterator + '_ { .map(|(&a,&b)| [a,b]) } +pub fn all_flippings(shape: &Shape) -> impl Iterator + '_ { + iter::repeat([false,true].into_iter()) + .take(DIM) + .multi_cartesian_product() + .map(|inv: Vec| { + shape.iter().map(|p| { + let mut inv = inv.iter(); + p.map(|c| { + if *inv.next().unwrap() { MAX-c } else { c } + }) + }) + .collect_vec() + }) +} + pub fn print_shape(shape: &Shape) -> io::Result<()> { let mut o = io::stdout().lock(); for vx in shape {