From b48dd87feeacfd3f8007ab2f34862523c9a9c1dd Mon Sep 17 00:00:00 2001 From: Michael Preisach Date: Fri, 25 May 2018 02:31:35 +0200 Subject: [PATCH] first two levels work --- .gitignore | 2 ++ .idea/misc.xml | 12 ++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ Cargo.lock | 4 ++++ Cargo.toml | 6 ++++++ adventofcode2015.iml | 15 +++++++++++++++ src/main.rs | 39 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 92 insertions(+) create mode 100644 .gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 adventofcode2015.iml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eccd7b4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target/ +**/*.rs.bk diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..70bebef --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3463e6b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..220146c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "adventofcode2015" +version = "0.1.0" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..ba6d3d3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "adventofcode2015" +version = "0.1.0" +authors = ["Michael Preisach "] + +[dependencies] diff --git a/adventofcode2015.iml b/adventofcode2015.iml new file mode 100644 index 0000000..7fe828a --- /dev/null +++ b/adventofcode2015.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e3f8ecd --- /dev/null +++ b/src/main.rs @@ -0,0 +1,39 @@ +mod day1; +mod day2; +mod tests; + + +use std::fs::File; +use std::io::Read; + +fn main() { + match File::open("day1.txt") { + Ok(mut f) => { + let mut input = String::new(); + match f.read_to_string(&mut input) { + Ok(_) => (), + Err(msg) => println!("{}",msg), + } + let mut d1 = day1::Data::new(); + d1.parse(input); + println!("day1 floor: {}", d1.floor()); + println!("day1 basement: {}", d1.basement()); + } + Err(msg) => println!("{}",msg), + }; + + match File::open("day2.txt") { + Ok(mut f) => { + let mut input = String::new(); + match f.read_to_string(&mut input) { + Ok(_) => (), + Err(msg) => println!("{}",msg), + } + let mut d2 = day2::Data::new(); + d2.parse(input); + println!("day2 paper: {}", d2.paper()); + println!("day2 ribbon: {}", d2.ribbon()); + } + Err(msg) => println!("{}",msg), + }; +}