aoc

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

common.rs (413B)


      1 pub type Grid = Vec<Vec<(i8, bool)>>;
      2 
      3 pub fn read_grid_from_stdin() -> Grid {
      4     let mut grid = Vec::<Vec<(i8, bool)>>::new();
      5     let mut line = String::new();
      6     while std::io::stdin().read_line(&mut line).unwrap() > 0 {
      7         let row = line[..line.len()-1].as_bytes().iter()
      8             .map(|b| ((*b as i8) - ('0' as i8), false)).collect();
      9         grid.push(row);
     10         line.clear();
     11     }
     12     grid
     13 }