diff --git a/2021/src/bin/day04.rs b/2021/src/bin/day04.rs index d08c1e4..100a943 100644 --- a/2021/src/bin/day04.rs +++ b/2021/src/bin/day04.rs @@ -1,14 +1,12 @@ #![feature(test)] extern crate test; -use std::collections::HashSet; - use aoc2021::common::*; use itertools::Itertools; const DAY: usize = 4; const BOARD_SIZE: usize = 5; const NUMBERS_PER_BOARD: usize = BOARD_SIZE * BOARD_SIZE; -type Board = Vec>; +type Board = Vec>; #[derive(Debug, Clone)] struct BingoGame { @@ -19,8 +17,10 @@ struct BingoGame { impl BingoGame { fn mark_number(&mut self, n: &u8) { for board in self.boards.iter_mut() { + // Actually using sets instead of vectors here takes twice as long, + // so just pretend these are actually sets. for winning_set in board.iter_mut() { - winning_set.remove(n); + winning_set.retain(|e| e != n); } } }