fn main() -> io::Result<()> {
for shape in read_vertices() {
-
-
- let has_all_corners =
- iter::repeat([0,MAX].into_iter())
- .take(DIM)
- .multi_cartesian_product()
- .all(|need| shape.iter().any(|got| &got[..]==need));
-
- if !has_all_corners { continue }
-
- if !has_all_corners { continue }
-
- let middle_vertices =
- iter::repeat([1,2].into_iter())
- .take(DIM)
- .multi_cartesian_product()
- .filter(|need| shape.iter().any(|got| &got[..]==need))
- .count();
-
- print!("{} ", middle_vertices);
-
- let mut edges_middlish = [0; 3];
-
- for ab in shape_edges(&shape) {
- let middles = ab.iter().filter(|p| point_middle(p)).count();
- edges_middlish[middles] += 1;
- }
-
- for em in &edges_middlish {
- print!("{:2} ", em);
+ for shape2 in shape_all_flippings(&shape) {
+ print_shape(&shape2)?;
}
-
- print_shape(&shape)?;
}
Ok(())
io::stdin().lines().map(|l| {
let l = l.unwrap();
let mut current: Point = default();
- l.chars().map(|cx| {
+ let mut points = l.chars().map(|cx| {
let cl = cx.to_ascii_lowercase();
let d = if cx == cl { -1 } else { 1 };
let i = cl as usize - 'x' as usize;
current[i] += d;
current
- }).collect()
+ }).collect_vec();
+ for i in 0..DIM {
+ let min = points.iter().map(|p| p[i]).min().unwrap();
+ for p in &mut points { p[i] -= min; }
+ }
+ points
})
}
.map(|(&a,&b)| [a,b])
}
-pub fn all_flippings(shape: &Shape) -> impl Iterator<Item=Shape> + '_ {
+pub fn shape_all_flippings(shape: &Shape) -> impl Iterator<Item=Shape> + '_ {
iter::repeat([false,true].into_iter())
.take(DIM)
.multi_cartesian_product()