day16: part 1 solution
All checks were successful
test / AoC 2024 (push) Successful in 2m56s

This commit is contained in:
2024-12-15 22:06:12 -08:00
parent f2186d18d3
commit 6283ff37f9
5 changed files with 189 additions and 4 deletions

View File

@ -7,7 +7,7 @@ use std::{
str::FromStr,
};
#[derive(Clone, Debug)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct Coord2d {
pub x: i64,
pub y: i64,
@ -126,7 +126,7 @@ pub struct Grid<T> {
width: i64,
}
impl<T: Clone + Eq + PartialEq + Display + Debug> Grid<T> {
impl<T: Clone + Eq + PartialEq + Debug> Grid<T> {
pub fn new(width: i64) -> Self {
Self {
data: Vec::new(),
@ -134,7 +134,7 @@ impl<T: Clone + Eq + PartialEq + Display + Debug> Grid<T> {
}
}
/// Returns a new [Grid] with the same shape (width x height) as `self`, filled with `fill`
pub fn same_shape<NT: Clone + Eq + PartialEq + Display + Debug>(&self, fill: NT) -> Grid<NT> {
pub fn same_shape<NT: Clone + Eq + PartialEq + Debug>(&self, fill: NT) -> Grid<NT> {
Grid {
data: Vec::from_iter(repeat(fill).take(self.width() * self.height())),
width: self.width,