day18: part 1 solution

This commit is contained in:
2024-12-17 21:52:36 -08:00
parent 9be86e2cc2
commit 5036866663
5 changed files with 169 additions and 5 deletions

View File

@ -285,6 +285,24 @@ impl Display for Grid<u8> {
}
}
impl Display for Grid<bool> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
for y in 0..self.height() {
for x in 0..self.width() {
f.write_fmt(format_args!(
"{}",
match *self.get(&(x as i64, y as i64)).unwrap() {
true => '.',
false => '#',
}
))?;
}
f.write_char('\n')?;
}
f.write_char('\n')
}
}
#[cfg(test)]
mod tests {
use super::*;