Day One solution
This commit is contained in:
parent
ba32fa8032
commit
42861d1149
1 changed files with 61 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
|||
#![allow(unused)]
|
||||
|
||||
use std::fmt::format;
|
||||
|
||||
use aoc_2023::Args;
|
||||
use clap::Parser;
|
||||
|
||||
|
@ -11,7 +13,7 @@ fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
let path = format!("./inputs/{day}.txt");
|
||||
let path = format!("./inputs/{day}.txt");
|
||||
let input = std::fs::read_to_string(path).unwrap();
|
||||
|
||||
match day {
|
||||
|
@ -45,74 +47,131 @@ fn main() {
|
|||
}
|
||||
|
||||
fn day_1(input: String) {
|
||||
todo!()
|
||||
let mut result = vec![];
|
||||
|
||||
// Yes this is very ugly, I don't care lol
|
||||
let input = input.replace("one", "o1e");
|
||||
let input = input.replace("two", "t2o");
|
||||
let input = input.replace("three", "t3e");
|
||||
let input = input.replace("four", "f4r");
|
||||
let input = input.replace("five", "f5e");
|
||||
let input = input.replace("six", "s6x");
|
||||
let input = input.replace("seven", "s7n");
|
||||
let input = input.replace("eight", "e8t");
|
||||
let input = input.replace("nine", "n9e");
|
||||
|
||||
for value in input
|
||||
.lines()
|
||||
.map(|line| {
|
||||
line.chars()
|
||||
.filter(|char| char.is_numeric())
|
||||
.map(|char| char.to_string())
|
||||
.collect::<String>()
|
||||
})
|
||||
.collect::<Vec<String>>()
|
||||
{
|
||||
let first = value.chars().next().unwrap();
|
||||
let second = match value.chars().last() {
|
||||
None => first,
|
||||
Some(v) => v,
|
||||
};
|
||||
|
||||
result.push(format!("{first}{second}"));
|
||||
}
|
||||
|
||||
let result: usize = result.iter().map(|v| v.parse::<usize>().unwrap()).sum();
|
||||
|
||||
println!("{result:?}");
|
||||
}
|
||||
|
||||
fn day_2(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_3(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_4(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_5(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_6(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_7(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_8(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_9(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_10(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_11(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_12(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_13(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_14(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_15(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_16(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_17(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_18(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_19(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_20(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_21(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_22(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_23(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn day_24(input: String) {
|
||||
todo!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue