Skip to content

Commit 1e79a38

Browse files
author
thom
committed
Day12 prelim
1 parent 97e8cfc commit 1e79a38

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

2017/day12/src/main.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
11
extern crate regex;
22
use regex::Regex;
33

4+
#[derive(Debug)]
5+
struct Program {
6+
id: u32,
7+
connections: Vec<u32>,
8+
}
9+
410
fn main() {
511
let re = Regex::new(r"(\d+) <-> (.+)").unwrap();
612

713
let lines: Vec<&str> = INPUT.split("\n").filter(|&s| s.len() != 0).collect();
814

9-
println!("{:?}", lines);
15+
let mut programs: Vec<Program> = Vec::new();
16+
17+
for datum in lines {
18+
let capt = re.captures(datum).unwrap();
19+
20+
let prog = Program {
21+
id: capt.get(1).unwrap().as_str().parse::<u32>().unwrap(),
22+
connections: capt.get(2)
23+
.unwrap()
24+
.as_str()
25+
.split(", ")
26+
.map(|s| s.to_string().parse::<u32>().unwrap())
27+
.collect(),
28+
};
29+
30+
programs.push(prog);
31+
}
32+
33+
let programs = programs;
34+
35+
let mut groups: Vec<Vec<u32>> = Vec::new();
36+
37+
println!("{:#?}", programs);
1038
}
1139

1240
// --- Day 12: Digital Plumber ---

0 commit comments

Comments
 (0)