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

20 lines
423 B
Rust
Raw Normal View History

2024-09-12 09:51:31 +00:00
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)
}