-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday11.rs
47 lines (40 loc) · 1.47 KB
/
day11.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::fs::File;
use std::io::prelude::*;
fn main()
{
// get file
let mut input_file = File::open("input_day11.txt").expect("No file exists");
// read to string
let mut input = String::new();
input_file.read_to_string(&mut input).expect("Read to string failed");
input = input.trim().to_owned();
// parse to src vector of strings, delimit by ','
let mut src : Vec<&str> = input.split(",").collect();
// create dest vector of strings
let mut dest : Vec<&str> = Vec::new();
// get chunk iterator over src vector
for slice in src.chunks(2)
{
// match with collapsable patterns eg. (ne,nw) -> n, or (ne,sw) -> NULL
//match slice
//{
// &["ne", "nw"] => println!("n"),
// &["nw", "ne"] => println!("n"),
// &["se", "sw"] => println!("s"),
// &["sw", "se"] => println!("s"),
// &["nw", "se"] => println!("stay"),
// &["se", "nw"] => println!("stay"),
// &["ne", "sw"] => println!("stay"),
// &["sw", "ne"] => println!("stay"),
// &["n", "s"] => println!("stay"),
// &["s", "n"] => println!("stay"),
// &[a , b] => println!("{}\n{}", a, b),
// &[c] => println!("{}", c)
//}
}
// push each in pattern if no match, else push simplified direction to dest
// swap contents of vectors
// clear dest vector
// repeat until no longer can simplify
// print length of vector
}