day14: pretty print a tree

This commit is contained in:
2024-12-13 23:05:30 -08:00
parent c6153663b5
commit e8a38e7b24
3 changed files with 89 additions and 15 deletions

View File

@ -1,4 +1,5 @@
use aoc_runner_derive::aoc;
use colored::Colorize;
use grid::{AsCoord2d, Coord2d, Grid};
use regex::Regex;
use std::str::FromStr;
@ -77,13 +78,13 @@ fn display(robots: &Vec<Robot>, bounds: (i64, i64)) {
print!(
"{}",
if *grid.get(&(col, row)).unwrap() != 0 {
""
"".green()
} else {
" "
" ".color(colored::Color::Black)
}
);
}
println!(" EOL");
println!();
}
}
@ -136,6 +137,7 @@ pub fn part2(input: &str) -> u64 {
.filter(|c| !c.is_empty() && c[0] != 0)
.any(|c| c.len() > width as usize / 10)
{
display(&robots, (width, height));
return i;
}
}