aboutsummaryrefslogtreecommitdiff
path: root/src/day14pt1.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/day14pt1.rs')
-rw-r--r--src/day14pt1.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/day14pt1.rs b/src/day14pt1.rs
new file mode 100644
index 0000000..9b68f62
--- /dev/null
+++ b/src/day14pt1.rs
@@ -0,0 +1,23 @@
+pub fn main() {
+ let txt = std::fs::read_to_string("./input/day14.txt").unwrap();
+ let input = txt
+ .lines()
+ .map(|s| s.chars().collect::<Vec<char>>())
+ .collect::<Vec<Vec<char>>>();
+
+ let mut sum: u64 = 0;
+
+ for j in 0..input[0].len() {
+ let mut off: u64 = 0;
+ for i in 0..input.len() {
+ if input[i][j] == 'O' {
+ sum += input.len() as u64 - off;
+ off += 1;
+ } else if input[i][j] == '#' {
+ off = (i + 1) as u64;
+ }
+ }
+ }
+
+ println!("{}", sum);
+}