Added day 1 part 1
This commit is contained in:
commit
4d6baa1e1d
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal 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
6
Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "aoc2022"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
2239
inputs/input.txt
Normal file
2239
inputs/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
16
inputs/sample.txt
Normal file
16
inputs/sample.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
1000
|
||||
2000
|
||||
3000
|
||||
|
||||
4000
|
||||
|
||||
5000
|
||||
6000
|
||||
|
||||
7000
|
||||
8000
|
||||
9000
|
||||
|
||||
10000
|
||||
|
||||
|
34
src/main.rs
Normal file
34
src/main.rs
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user