Run cargo fmt
This commit is contained in:
parent
fe14fed68c
commit
6bfae0fe45
|
@ -18,4 +18,4 @@ fn main() {
|
||||||
"2023" => year_2023::run(day),
|
"2023" => year_2023::run(day),
|
||||||
_ => panic!("Invalid year specified"),
|
_ => panic!("Invalid year specified"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,10 @@ use std::fs::File;
|
||||||
use std::io::{self, BufRead};
|
use std::io::{self, BufRead};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
||||||
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
pub fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>>
|
||||||
where
|
where
|
||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let file = File::open(filename)?;
|
let file = File::open(filename)?;
|
||||||
Ok(io::BufReader::new(file).lines())
|
Ok(io::BufReader::new(file).lines())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
pub mod input_reader;
|
pub mod input_reader;
|
||||||
pub mod solution;
|
pub mod solution;
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::utils::solution::Solution;
|
||||||
pub struct Day1Solution;
|
pub struct Day1Solution;
|
||||||
|
|
||||||
impl Solution for Day1Solution {
|
impl Solution for Day1Solution {
|
||||||
fn part_one(&self) -> String{
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
part_one::part_one()
|
part_one::part_one()
|
||||||
|
@ -17,4 +17,4 @@ impl Solution for Day1Solution {
|
||||||
// ...
|
// ...
|
||||||
part_two::part_two()
|
part_two::part_two()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ pub fn part_two() -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn parse_line(s: &str) -> u32 {
|
fn parse_line(s: &str) -> u32 {
|
||||||
const RADIX: u32 = 10;
|
const RADIX: u32 = 10;
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::utils::solution::Solution;
|
||||||
pub struct Day2Solution;
|
pub struct Day2Solution;
|
||||||
|
|
||||||
impl Solution for Day2Solution {
|
impl Solution for Day2Solution {
|
||||||
fn part_one(&self) -> String{
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
part_one::part_one()
|
part_one::part_one()
|
||||||
|
@ -17,4 +17,4 @@ impl Solution for Day2Solution {
|
||||||
// ...
|
// ...
|
||||||
part_two::part_two()
|
part_two::part_two()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::utils::input_reader;
|
use crate::utils::input_reader;
|
||||||
|
|
||||||
pub fn part_one() -> String{
|
pub fn part_one() -> String {
|
||||||
if let Ok(lines) = input_reader::read_lines("./input/2023/day_02/input.txt") {
|
if let Ok(lines) = input_reader::read_lines("./input/2023/day_02/input.txt") {
|
||||||
let mut result = 0;
|
let mut result = 0;
|
||||||
|
|
||||||
|
|
|
@ -22,15 +22,13 @@ pub fn part_two() -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn process_line(s: &str) -> u32 {
|
fn process_line(s: &str) -> u32 {
|
||||||
let v: Vec<&str> = s.split(':').collect();
|
let v: Vec<&str> = s.split(':').collect();
|
||||||
|
|
||||||
v[0].split("Game ").collect::<Vec<&str>>()[1]
|
v[0].split("Game ").collect::<Vec<&str>>()[1]
|
||||||
.parse::<u32>()
|
.parse::<u32>()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let games: Vec<&str> = v[1].split(';').collect();
|
let games: Vec<&str> = v[1].split(';').collect();
|
||||||
|
|
||||||
let mut min_game = Game {
|
let mut min_game = Game {
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
pub mod part_one;
|
pub mod part_one;
|
||||||
|
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
use crate::utils::solution::Solution;
|
||||||
|
|
||||||
pub struct Day3Solution;
|
pub struct Day3Solution;
|
||||||
|
|
||||||
impl Solution for Day3Solution {
|
impl Solution for Day3Solution {
|
||||||
fn part_one(&self) -> String{
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
part_one::part_one()
|
part_one::part_one()
|
||||||
|
@ -17,4 +16,4 @@ impl Solution for Day3Solution {
|
||||||
// ...
|
// ...
|
||||||
String::from("Not implemented")
|
String::from("Not implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub fn part_one() -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn create_matrix(lines: io::Lines<io::BufReader<File>>) -> Vec<Vec<Engine>> {
|
fn create_matrix(lines: io::Lines<io::BufReader<File>>) -> Vec<Vec<Engine>> {
|
||||||
let mut matrix: Vec<Vec<Engine>> = Vec::new();
|
let mut matrix: Vec<Vec<Engine>> = Vec::new();
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
pub mod part_one;
|
pub mod part_one;
|
||||||
|
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
use crate::utils::solution::Solution;
|
||||||
|
|
||||||
pub struct Day4Solution;
|
pub struct Day4Solution;
|
||||||
|
|
||||||
impl Solution for Day4Solution {
|
impl Solution for Day4Solution {
|
||||||
fn part_one(&self) -> String{
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
part_one::part_one()
|
part_one::part_one()
|
||||||
|
@ -17,4 +16,4 @@ impl Solution for Day4Solution {
|
||||||
// ...
|
// ...
|
||||||
String::from("Not implemented")
|
String::from("Not implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ pub fn part_one() -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_line(s: &str) -> u32 {
|
fn process_line(s: &str) -> u32 {
|
||||||
|
|
||||||
let mut winning_numbers = HashSet::new();
|
let mut winning_numbers = HashSet::new();
|
||||||
let mut res = 0;
|
let mut res = 0;
|
||||||
|
|
||||||
|
@ -45,5 +44,3 @@ fn process_line(s: &str) -> u32 {
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
pub mod part_one;
|
pub mod part_one;
|
||||||
pub mod part_two;
|
pub mod part_two;
|
||||||
|
|
||||||
|
|
||||||
use crate::utils::solution::Solution;
|
use crate::utils::solution::Solution;
|
||||||
|
|
||||||
pub struct Day6Solution;
|
pub struct Day6Solution;
|
||||||
|
|
||||||
impl Solution for Day6Solution {
|
impl Solution for Day6Solution {
|
||||||
fn part_one(&self) -> String{
|
fn part_one(&self) -> String {
|
||||||
// Implementation for part one of day 1
|
// Implementation for part one of day 1
|
||||||
// ...
|
// ...
|
||||||
part_one::part_one()
|
part_one::part_one()
|
||||||
|
@ -18,4 +17,4 @@ impl Solution for Day6Solution {
|
||||||
// ...
|
// ...
|
||||||
part_two::part_two()
|
part_two::part_two()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,5 +40,3 @@ fn process_race_result(time: u32, distance: u32) -> u32 {
|
||||||
|
|
||||||
return win_count;
|
return win_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,5 +37,3 @@ fn process_race_result(time: u64, distance: u64) -> u64 {
|
||||||
|
|
||||||
return win_count;
|
return win_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,4 +19,4 @@ pub fn run(day: &str) {
|
||||||
// Call part_one and part_two on the solution instance
|
// Call part_one and part_two on the solution instance
|
||||||
println!("Part One Result: {}", solution.part_one());
|
println!("Part One Result: {}", solution.part_one());
|
||||||
println!("Part Two Result: {}", solution.part_two());
|
println!("Part Two Result: {}", solution.part_two());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue