Update.
This commit is contained in:
parent
6245e1a17c
commit
066a5894d3
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
|||||||
/target
|
/target
|
||||||
.idea
|
.idea
|
||||||
|
.fleet
|
||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
debug/
|
debug/
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
|
|
||||||
pub fn solve_part1(file_path: &str) -> i32 {
|
pub fn solve_part1(file_path: &str) -> i32 {
|
||||||
let contents =
|
|
||||||
std::fs::read_to_string(file_path).expect("Please provide a text file as an argument.");
|
|
||||||
let lines: Vec<&str> = contents.split('\n').collect();
|
|
||||||
|
|
||||||
let mut max = 0;
|
let mut max = 0;
|
||||||
let mut accumulated = 0;
|
let mut accumulated = 0;
|
||||||
lines.iter().for_each(|number| {
|
std::fs::read_to_string(file_path)
|
||||||
|
.unwrap_or_else(|err| panic!("Please provide a text file as an argument: {err}"))
|
||||||
|
.lines()
|
||||||
|
.for_each(|number| {
|
||||||
if let Ok(yay) = number.parse::<i32>() {
|
if let Ok(yay) = number.parse::<i32>() {
|
||||||
accumulated += yay;
|
accumulated += yay;
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,7 +114,7 @@ fn parser(content: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn solve(file_path: &str) -> i32 {
|
pub fn solve(file_path: &str) -> i32 {
|
||||||
let content = std::fs::read_to_string(file_path).expect("Please provide a file.");
|
let content = std::fs::read_to_string(file_path).unwrap_or_else(|err| panic!("{err}"));
|
||||||
parser(&content);
|
parser(&content);
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user