diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-02 11:21:58 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-02 11:21:58 +0200 |
| commit | bce2009698f7ef4ba066ee5122500fe32c1289cd (patch) | |
| tree | f20b6a5375fa6d68feb74a99a864680a01435d44 /2022/14/a.rs | |
| parent | 7e4982be44b980ccbe00c88a66abd773dba62f1a (diff) | |
| download | aoc-bce2009698f7ef4ba066ee5122500fe32c1289cd.tar.gz aoc-bce2009698f7ef4ba066ee5122500fe32c1289cd.zip | |
Day 14 2022
Diffstat (limited to '2022/14/a.rs')
| -rw-r--r-- | 2022/14/a.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/2022/14/a.rs b/2022/14/a.rs new file mode 100644 index 0000000..e775c23 --- /dev/null +++ b/2022/14/a.rs | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | mod common; | ||
| 2 | use common::*; | ||
| 3 | |||
| 4 | fn drop(map: &mut Map, i: (usize, usize)) -> bool { | ||
| 5 | let (x, y) = i; | ||
| 6 | if y > map.ymax { return false; } | ||
| 7 | |||
| 8 | for j in vec![(x, y+1), (x-1, y+1), (x+1, y+1)].into_iter() { | ||
| 9 | if !map.at(j) { return drop(map, j); } | ||
| 10 | } | ||
| 11 | |||
| 12 | map[i] = true; | ||
| 13 | true | ||
| 14 | } | ||
| 15 | |||
| 16 | fn 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}"); | ||
| 22 | } | ||
