fix: tests for day 11

This commit is contained in:
Matej Janezic 2023-12-13 15:01:34 +01:00
parent 0000026098
commit 000002707d
Signed by: janezicmatej
GPG Key ID: 4298E230ED37B2C0
1 changed files with 4 additions and 8 deletions

View File

@ -2,20 +2,16 @@ use std::collections::HashSet;
fn parse_input(input: &str) -> (Vec<(usize, usize)>, HashSet<usize>, HashSet<usize>) {
let mut galaxies = Vec::new();
let mut rows = HashSet::new();
let mut columns = HashSet::from_iter(1..(input.lines().next().unwrap().len()));
let mut rows = HashSet::from_iter(0..input.lines().count());
let mut columns = HashSet::from_iter(0..input.lines().next().unwrap().len());
for (y, line) in input.lines().enumerate() {
let mut found = false;
for (x, c) in line.chars().enumerate() {
if c == '#' {
galaxies.push((y, x));
found = true;
rows.remove(&y);
columns.remove(&x);
}
columns.remove(&x);
}
if !found {
rows.insert(y);
}
}