chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:57:02 +0000 (19:57 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Oct 2022 18:57:02 +0000 (19:57 +0100)
Cargo.lock [new file with mode: 0644]
src/bin/vertices.rs [new file with mode: 0644]
src/lib.rs
src/main.rs

diff --git a/Cargo.lock b/Cargo.lock
new file mode 100644 (file)
index 0000000..105a391
--- /dev/null
@@ -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 (file)
index 0000000..b814033
--- /dev/null
@@ -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")?;
+  }
+}
index 8337712ea57f00733b5709b27efb3de797e95575..6821d14d29745a442cae843d60cc5d37c572355b 100644 (file)
@@ -1 +1,23 @@
 //
+
+pub use std::io;
+
+pub fn default<T: Default>() -> T { Default::default() }
+
+pub const DIM: usize = 3;
+pub type Coord = i8;
+pub type Point = [Coord; DIM];
+
+pub fn read_vertices() -> impl Iterator<Itme=Vec<Point>> {
+  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()
+  }
+}
index e7a11a969c037e00a796aafeff6258501ec15e9a..80a1832bfa35d8a47cbd8b56cec6c9479ccad34d 100644 (file)
@@ -1,3 +1,3 @@
 fn main() {
-    println!("Hello, world!");
+  println!("Hello, world!");
 }