End of day commit, nothing works. Will be using a parsing library (nom)
This commit is contained in:
parent
660cca5d23
commit
0408d3e148
5 changed files with 543 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
pub mod prob1;
|
||||
pub mod prob2;
|
||||
pub mod prob3;
|
||||
pub mod prob4;
|
||||
pub mod prob4;
|
||||
pub mod prob5;
|
|
@ -1,4 +1,4 @@
|
|||
use advent_of_code::{prob1, prob2, prob3, prob4};
|
||||
use advent_of_code::{prob1, prob2, prob3, prob4, prob5};
|
||||
|
||||
fn main() {
|
||||
{
|
||||
|
@ -33,4 +33,9 @@ fn main() {
|
|||
let max_part1 = prob4::solve(file_path, &prob4::complete_overlap);
|
||||
println!("Solution for problem 4 part 2: {max_part1}");
|
||||
}
|
||||
{
|
||||
let file_path = "prob5_part1.txt";
|
||||
let max_part1 = prob5::solve(file_path);
|
||||
println!("Solution for problem 5 part 1: {max_part1}");
|
||||
}
|
||||
}
|
||||
|
|
23
src/prob5.rs
Normal file
23
src/prob5.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
fn parser(content: &str) {
|
||||
let output = content
|
||||
.lines()
|
||||
.filter(|item| !item.starts_with("move"))
|
||||
.flat_map(|line| {
|
||||
let splitted = line
|
||||
.trim()
|
||||
.split(' ')
|
||||
.enumerate()
|
||||
.filter(|item| !item.1.contains(' '))
|
||||
.filter(|item| !item.1.is_empty())
|
||||
.collect::<Vec<(usize, &str)>>();
|
||||
println!("{splitted:?}");
|
||||
splitted
|
||||
})
|
||||
.collect::<Vec<(usize, &str)>>();
|
||||
}
|
||||
|
||||
pub fn solve(file_path: &str) -> i32 {
|
||||
let content = std::fs::read_to_string(file_path).expect("Please provide a file.");
|
||||
parser(&content);
|
||||
0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue