Added day 1 pt 1
This commit is contained in:
commit
6b000c42d1
|
@ -0,0 +1 @@
|
||||||
|
/target
|
|
@ -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…
Reference in New Issue