2021: day04: remove useless Grid field
This commit is contained in:
parent
6dccc14046
commit
9209659a5a
|
@ -99,7 +99,6 @@ fn part2(input: &str) -> Result<u64> {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Grid {
|
struct Grid {
|
||||||
number_to_pos: HashMap<u8, (usize, usize)>,
|
number_to_pos: HashMap<u8, (usize, usize)>,
|
||||||
pos_to_number: HashMap<(usize, usize), u8>,
|
|
||||||
grid: [bool; GRID_SIZE],
|
grid: [bool; GRID_SIZE],
|
||||||
rows: [u8; GRID_HEIGHT],
|
rows: [u8; GRID_HEIGHT],
|
||||||
cols: [u8; GRID_WIDTH],
|
cols: [u8; GRID_WIDTH],
|
||||||
|
@ -141,7 +140,6 @@ impl std::str::FromStr for Grid {
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
let mut numbers = s.split_whitespace().map(str::parse);
|
let mut numbers = s.split_whitespace().map(str::parse);
|
||||||
let mut number_to_pos = HashMap::new();
|
let mut number_to_pos = HashMap::new();
|
||||||
let mut pos_to_number = HashMap::new();
|
|
||||||
|
|
||||||
for y in 0..GRID_HEIGHT {
|
for y in 0..GRID_HEIGHT {
|
||||||
for x in 0..GRID_WIDTH {
|
for x in 0..GRID_WIDTH {
|
||||||
|
@ -151,13 +149,11 @@ impl std::str::FromStr for Grid {
|
||||||
.context("not enough numbers for grid")?
|
.context("not enough numbers for grid")?
|
||||||
.context("couldn't parse number:")?;
|
.context("couldn't parse number:")?;
|
||||||
number_to_pos.insert(number, pos);
|
number_to_pos.insert(number, pos);
|
||||||
pos_to_number.insert(pos, number);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Grid {
|
Ok(Grid {
|
||||||
number_to_pos,
|
number_to_pos,
|
||||||
pos_to_number,
|
|
||||||
grid: [false; GRID_SIZE],
|
grid: [false; GRID_SIZE],
|
||||||
rows: [0; GRID_HEIGHT],
|
rows: [0; GRID_HEIGHT],
|
||||||
cols: [0; GRID_WIDTH],
|
cols: [0; GRID_WIDTH],
|
||||||
|
|
Loading…
Reference in a new issue