summaryrefslogtreecommitdiff
path: root/day7/src
diff options
context:
space:
mode:
Diffstat (limited to 'day7/src')
-rw-r--r--day7/src/main.rs29
1 files changed, 0 insertions, 29 deletions
diff --git a/day7/src/main.rs b/day7/src/main.rs
deleted file mode 100644
index 26e1e30..0000000
--- a/day7/src/main.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use std::fs::File;
-use std::io::{BufRead, BufReader};
-
-fn main() -> std::io::Result<()> {
- let file = File::open("input.txt")?;
- let mut reader = BufReader::new(file);
- let mut buffer = String::new();
- reader.read_line(&mut buffer)?;
-
- let mut inputs: Vec<_> = buffer
- .trim()
- .split(',')
- .map(|x| x.parse::<i16>().unwrap())
- .collect::<Vec<i16>>();
-
- inputs.sort();
-
- let half: usize = inputs.len() / 2;
- let middle = inputs[half];
- let mut sum: u32 = 0;
-
- for input in inputs {
- sum += (input - middle).abs() as u32;
- }
-
- println!("{}", sum);
-
- Ok(())
-}