b.rs (521B)
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 { 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 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+1); 22 }