aoc

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

common.rs (511B)


      1 pub fn get_elves_from_stdin() -> Vec<Vec<i64>> {
      2     let mut e = Vec::<Vec::<i64>>::new();
      3     e.push(Vec::<i64>::new());
      4     let mut line = String::new();
      5     loop {
      6         match std::io::stdin().read_line(&mut line).unwrap() {
      7             0 => break,
      8             1 => e.push(Vec::<i64>::new()),
      9             _ => {
     10                 let n = line.trim().parse::<i64>().unwrap();
     11                 let last = e.len() - 1;
     12                 e[last].push(n);
     13             }
     14         }
     15         line.clear();
     16     }
     17     e
     18 }