100-days-of-rust/Week-07/Day-49_Swimming-Pool/day49/src/lib.rs

20 lines
423 B
Rust

pub fn is_legitimate(pool: &[Vec<u8>]) -> Option<bool> {
for row in pool {
if *row.first()? == 1 || *row.last()? == 1 {
return Some(false);
}
}
for first_row in pool.first()? {
if *first_row == 1 {
return Some(false);
}
}
for last_row in pool.last()? {
if *last_row == 1 {
return Some(false);
}
}
Some(true)
}