1
0
Fork 0

Added day 1 pt 1

This commit is contained in:
Ishan Jain 2021-12-01 10:46:08 +05:30
commit 6b000c42d1
5 changed files with 2041 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View File

@ -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"

8
Cargo.toml Normal file
View File

@ -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]

2003
inputs/day1.txt Normal file

File diff suppressed because it is too large Load Diff

22
src/main.rs Normal file
View File

@ -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);
}