[2018][rust][1.0]
change xqttprtpvwyuvvsutuupqyotswrvwnsv
commit 3e30e0ca97a81a0e49335a375277b9c7c3d2ffa8
author Alpha Chen <alpha.chen@gmail.com>
date
parent kwomlyys
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..680a797
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+**/rust/target
diff --git a/2018/rust/Cargo.lock b/2018/rust/Cargo.lock
new file mode 100644
index 0000000..ec1441e
--- /dev/null
+++ b/2018/rust/Cargo.lock
@@ -0,0 +1,4 @@
+[[package]]
+name = "advent_of_code_2018"
+version = "0.1.0"
+
diff --git a/2018/rust/Cargo.toml b/2018/rust/Cargo.toml
new file mode 100644
index 0000000..0d393ec
--- /dev/null
+++ b/2018/rust/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "advent_of_code_2018"
+version = "0.1.0"
+authors = ["Alpha Chen <alpha.chen@gmail.com>"]
+edition = "2018"
+
+[dependencies]
diff --git a/2018/rust/src/main.rs b/2018/rust/src/main.rs
new file mode 100644
index 0000000..3acbb2e
--- /dev/null
+++ b/2018/rust/src/main.rs
@@ -0,0 +1,22 @@
+use std::io::{self, Read};
+
+fn day_1(input: &str, delimiter: &str) -> String {
+    let sum: i32 = input
+        .split(delimiter)
+        .flat_map(|change| change.parse::<i32>().ok())
+        .sum();
+    sum.to_string()
+}
+
+#[test]
+fn test_day_1() {
+    assert_eq!(day_1("+1, -2, +3, +1", ", "), "3");
+}
+
+fn main() {
+    let mut input = String::new();
+    io::stdin().read_to_string(&mut input).unwrap();
+
+    let output = day_1(&input, "\n");
+    println!("{}", output);
+}