aoc

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

common.rs (325B)


      1 pub fn get_score(play_score: fn(&[u8]) -> i64, win_score: fn(&[u8]) -> i64) -> i64 {
      2     let mut score = 0;
      3     let mut line = String::new();
      4     while std::io::stdin().read_line(&mut line).unwrap() > 0 {
      5         let l = line.as_bytes();
      6         score += play_score(l) + win_score(l);
      7         line.clear();
      8     }
      9     score
     10 }