mirror of
https://github.com/supleed2/cch23-8bit.git
synced 2024-12-22 22:15:49 +00:00
Day 6
This commit is contained in:
parent
0e264593c6
commit
0dade3be25
23
src/cal/day06.rs
Normal file
23
src/cal/day06.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use axum::{extract::Json, routing::post, Router};
|
||||||
|
|
||||||
|
pub(crate) fn router() -> Router {
|
||||||
|
Router::new().route("/6", post(count_elf))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(serde::Serialize)]
|
||||||
|
struct CountElf {
|
||||||
|
elf: usize,
|
||||||
|
elf_on_a_shelf: usize,
|
||||||
|
shelf_with_no_elf: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn count_elf(body: String) -> Json<CountElf> {
|
||||||
|
let elf = body.matches("elf").count();
|
||||||
|
let elf_on_a_shelf = body.matches("elf on a shelf").count();
|
||||||
|
let shelf_with_no_elf = body.matches("shelf").count() - elf_on_a_shelf;
|
||||||
|
Json(CountElf {
|
||||||
|
elf,
|
||||||
|
elf_on_a_shelf,
|
||||||
|
shelf_with_no_elf,
|
||||||
|
})
|
||||||
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
mod day00;
|
mod day00;
|
||||||
mod day01;
|
mod day01;
|
||||||
mod day04;
|
mod day04;
|
||||||
|
mod day06;
|
||||||
|
|
||||||
pub(crate) fn router() -> axum::Router {
|
pub(crate) fn router() -> axum::Router {
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.nest("/", day00::router())
|
.nest("/", day00::router())
|
||||||
.nest("/", day01::router())
|
.nest("/", day01::router())
|
||||||
.nest("/", day04::router())
|
.nest("/", day04::router())
|
||||||
|
.nest("/", day06::router())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue