1
0
Fork 0

Added day 1 part 1

This commit is contained in:
Ishan Jain 2022-12-01 10:37:17 +05:30
commit 4d6baa1e1d
Signed by: ishan
GPG Key ID: 0506DB2A1CC75C27
6 changed files with 2303 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 = "aoc2022"
version = "0.1.0"

6
Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "aoc2022"
version = "0.1.0"
edition = "2021"
[dependencies]

2239
inputs/input.txt Normal file

File diff suppressed because it is too large Load Diff

16
inputs/sample.txt Normal file
View File

@ -0,0 +1,16 @@
1000
2000
3000
4000
5000
6000
7000
8000
9000
10000

34
src/main.rs Normal file
View File

@ -0,0 +1,34 @@
#![feature(test)]
extern crate test;
const INPUTS: [&'static str; 2] = [
include_str!("../inputs/sample.txt"),
include_str!("../inputs/input.txt"),
];
fn parse(input: &'static str) -> Vec<Vec<i64>> {
input
.trim()
.split("\n\n")
.map(|set| {
set.split('\n')
.map(|c| c.trim())
.map(|c| c.parse::<i64>().unwrap())
.collect()
})
.collect()
}
fn main() {
for input in INPUTS.iter() {
let output = parse(input);
let max = output
.into_iter()
.map(|c| c.into_iter().sum::<i64>())
.max()
.unwrap();
println!("{}", max);
}
}