day14: pretty print a tree
This commit is contained in:
parent
c6153663b5
commit
e8a38e7b24
91
Cargo.lock
generated
91
Cargo.lock
generated
@ -29,14 +29,6 @@ version = "0.2.21"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aoc-autobuild"
|
|
||||||
version = "0.3.0"
|
|
||||||
dependencies = [
|
|
||||||
"aoc-runner",
|
|
||||||
"aoc2024",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aoc-runner"
|
name = "aoc-runner"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@ -75,6 +67,7 @@ dependencies = [
|
|||||||
"atoi",
|
"atoi",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cached",
|
"cached",
|
||||||
|
"colored",
|
||||||
"grid",
|
"grid",
|
||||||
"itertools",
|
"itertools",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -149,6 +142,16 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "colored"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||||
|
dependencies = [
|
||||||
|
"lazy_static",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-deque"
|
name = "crossbeam-deque"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
@ -266,6 +269,12 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lazy_static"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.22"
|
version = "0.4.22"
|
||||||
@ -538,6 +547,72 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-sys"
|
||||||
|
version = "0.48.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||||
|
dependencies = [
|
||||||
|
"windows_aarch64_gnullvm",
|
||||||
|
"windows_aarch64_msvc",
|
||||||
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_msvc",
|
||||||
|
"windows_x86_64_gnu",
|
||||||
|
"windows_x86_64_gnullvm",
|
||||||
|
"windows_x86_64_msvc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.48.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.7.35"
|
version = "0.7.35"
|
||||||
|
@ -9,6 +9,7 @@ aoc-runner-derive = "0.3.0"
|
|||||||
atoi = "2.0.0"
|
atoi = "2.0.0"
|
||||||
bitflags = "2.6.0"
|
bitflags = "2.6.0"
|
||||||
cached = "0.54.0"
|
cached = "0.54.0"
|
||||||
|
colored = "2.1.0"
|
||||||
grid = { version = "0.1.0", path = "utils/grid" }
|
grid = { version = "0.1.0", path = "utils/grid" }
|
||||||
itertools = "0.13.0"
|
itertools = "0.13.0"
|
||||||
rayon = "1.10.0"
|
rayon = "1.10.0"
|
||||||
@ -18,7 +19,3 @@ thread_local = "1.1.8"
|
|||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = [ ".", "utils/grid", "target/aoc/aoc-autobuild" ]
|
|
||||||
default-members = [ ".", "utils/*" ]
|
|
@ -1,4 +1,5 @@
|
|||||||
use aoc_runner_derive::aoc;
|
use aoc_runner_derive::aoc;
|
||||||
|
use colored::Colorize;
|
||||||
use grid::{AsCoord2d, Coord2d, Grid};
|
use grid::{AsCoord2d, Coord2d, Grid};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@ -77,13 +78,13 @@ fn display(robots: &Vec<Robot>, bounds: (i64, i64)) {
|
|||||||
print!(
|
print!(
|
||||||
"{}",
|
"{}",
|
||||||
if *grid.get(&(col, row)).unwrap() != 0 {
|
if *grid.get(&(col, row)).unwrap() != 0 {
|
||||||
"█"
|
"█".green()
|
||||||
} else {
|
} 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)
|
.filter(|c| !c.is_empty() && c[0] != 0)
|
||||||
.any(|c| c.len() > width as usize / 10)
|
.any(|c| c.len() > width as usize / 10)
|
||||||
{
|
{
|
||||||
|
display(&robots, (width, height));
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user