aoc

My solutions for the Advent of Code
git clone https://git.tronto.net/aoc
Download | Log | Files | Refs | README

a.rs (450B)


      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 }