Replace HashSet with Vec for more brrrrr

This commit is contained in:
kageru 2021-12-04 13:38:17 +01:00
parent f7efb54d21
commit ea1339f018
Signed by: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -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<HashSet<u8>>;
type Board = Vec<Vec<u8>>;
#[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);
}
}
}