aboutsummaryrefslogtreecommitdiff
path: root/2022/14/b.rs
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-02 11:21:58 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-02 11:21:58 +0200
commitbce2009698f7ef4ba066ee5122500fe32c1289cd (patch)
treef20b6a5375fa6d68feb74a99a864680a01435d44 /2022/14/b.rs
parent7e4982be44b980ccbe00c88a66abd773dba62f1a (diff)
downloadaoc-bce2009698f7ef4ba066ee5122500fe32c1289cd.tar.gz
aoc-bce2009698f7ef4ba066ee5122500fe32c1289cd.zip
Day 14 2022
Diffstat (limited to '2022/14/b.rs')
-rw-r--r--2022/14/b.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/2022/14/b.rs b/2022/14/b.rs
new file mode 100644
index 0000000..f8a4829
--- /dev/null
+++ b/2022/14/b.rs
@@ -0,0 +1,22 @@
1mod common;
2use common::*;
3
4fn drop(map: &mut Map, i: (usize, usize)) -> bool {
5 let (x, y) = i;
6 if y < map.ymax {
7 for j in vec![(x, y+1), (x-1, y+1), (x+1, y+1)].into_iter() {
8 if !map.at(j) { return drop(map, j); }
9 }
10 }
11
12 map[i] = true;
13 !map.at((500, 0)) // Returns false after filling the last -> off by 1
14}
15
16fn main() {
17 let mut map = read_map_from_stdin();
18 let mut i = 0;
19 while drop(&mut map, (500, 0)) { i += 1; }
20 //map.print();
21 println!("{}", i+1);
22}

Generated with cgit - Back to sebastiano.tronto.net