Struct advent_of_code_2021::day_4::BingoCard[−][src]

struct BingoCard {
    numbers: HashMap<u8, (usize, usize)>,
    rows: [u8; 5],
    columns: [u8; 5],
}
Expand description

This represents the key information to know if a 5 x 5 bingo card has won.

Fields

numbers: HashMap<u8, (usize, usize)>

A Map indexing the remaining numbers to their co-ordinates on the grid

rows: [u8; 5]

A counter for each row, tracking how many numbers in that row have been removed

columns: [u8; 5]

A counter for each column, tracking how many numbers in that column have been removed

Implementations

If the card contains the provided number, remove it from the unmarked numbers, increment the count of marked numbers in the relevant row and column, then if either of these are now 5, the card has won - return true, otherwise return false.

If the number is not on the card, nothing changes, and return false.

The remaining numbers are the keys of the numbers hash map, as marked numbers are removed from the map.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.