summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorAndrew Guschin <guschin.drew@gmail.com>2022-04-06 11:01:50 +0400
committerAndrew Guschin <guschin.drew@gmail.com>2022-04-06 11:01:50 +0400
commit3a3c4309d5798f5ed622d06b3f9c97d7f7899727 (patch)
tree68e4267baf37afd8dbdb89d84908f6b366fbdbed /src/main.rs
Initial commit
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..3e6e952
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,40 @@
+use std::io::{self, BufRead};
+
+fn read_graph(line: String) -> (usize, Vec<Vec<u8>>) {
+ let mut chars: Vec<u8> = Vec::new();
+ for character in line.chars() {
+ chars.push((character as i32 - 63) as u8);
+ }
+ // TODO: spec allows multi-byte vector size
+ let n = chars[0] as usize;
+ let bytes = &chars[1..];
+
+ let mut mat: Vec<Vec<u8>> = vec![vec![0; n]; n];
+ let mut i = 0;
+ for col in 1..n {
+ for row in 0..col {
+ let bit: u8 = bytes[i / 6] >> (5 - i % 6) & 1;
+ mat[row][col] = bit;
+ mat[col][row] = bit;
+ i += 1;
+ }
+ }
+ return (n, mat);
+}
+
+fn main() {
+ let stdin = io::stdin();
+
+ for line in stdin.lock().lines() {
+ let (n, mat) = read_graph(line.unwrap());
+
+ println!("Vector of size {}", n);
+ for row in 0..n {
+ for col in 0..n {
+ print!("{} ", mat[row][col]);
+ }
+ println!("");
+ }
+ }
+
+}