Added day 1 pt 1

day8-work 1.1
Ishan Jain 1 year ago
commit 6b000c42d1
  1. 1
      .gitignore
  2. 7
      Cargo.lock
  3. 8
      Cargo.toml
  4. 2003
      inputs/day1.txt
  5. 22
      src/main.rs

1
.gitignore vendored

@ -0,0 +1 @@
/target

7
Cargo.lock generated

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aoc2021"
version = "0.1.0"

@ -0,0 +1,8 @@
[package]
name = "aoc2021"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

File diff suppressed because it is too large Load Diff

@ -0,0 +1,22 @@
const INPUT: &'static str = include_str!("../inputs/day1.txt");
fn depths() -> Vec<u64> {
INPUT
.lines()
.filter(|&x| !x.is_empty())
.map(|x| x.parse::<u64>().unwrap())
.collect()
}
fn main() {
let days = depths();
let mut count = 0;
for set in days.windows(2) {
if set[1] > set[0] {
count += 1;
}
}
println!("increased {} times", count);
}
Loading…
Cancel
Save