From ae55b9bba31743f9be24c20b44aa62f9b5ce0888 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 29 Oct 2022 19:57:02 +0100 Subject: [PATCH] wip --- Cargo.lock | 7 +++++++ src/bin/vertices.rs | 13 +++++++++++++ src/lib.rs | 22 ++++++++++++++++++++++ src/main.rs | 2 +- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Cargo.lock create mode 100644 src/bin/vertices.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..105a391 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "z3-treefoil" +version = "0.1.0" diff --git a/src/bin/vertices.rs b/src/bin/vertices.rs new file mode 100644 index 0000000..b814033 --- /dev/null +++ b/src/bin/vertices.rs @@ -0,0 +1,13 @@ + +fn main() -> io::Result { + let mut o = io::stdout().lock(); + for shape in read_vertices() { + for vx in shape { + for c in vx { + write!(o, "{}", c)?; + } + write!(o, ",", c)?; + } + write!(o, "\n")?; + } +} diff --git a/src/lib.rs b/src/lib.rs index 8337712..6821d14 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,23 @@ // + +pub use std::io; + +pub fn default() -> T { Default::default() } + +pub const DIM: usize = 3; +pub type Coord = i8; +pub type Point = [Coord; DIM]; + +pub fn read_vertices() -> impl Iterator> { + io::stdin().lines().map(|l| { + let l = l.unwrap(); + let mut current = default(); + l.chars().map(|cx| { + let cl = cx.to_ascii_lowercase(); + let d = if cx == cl { -1 } else { +1 }; + let i = cl as i8 - 'x'; + current[i] += d; + current + }).collect() + } +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..80a1832 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,3 @@ fn main() { - println!("Hello, world!"); + println!("Hello, world!"); } -- 2.30.2