fn find_minimal_safe_delay(layers: &Vec<Layer>) -> u32 {
    let mut delay: u32 = 0;
    loop {
        let mut caught: bool = false;
        for layer in layers {
            if (delay + layer.depth) % ((layer.range - 1) * 2) == 0 {
                caught = true;
                break;
            }
        }
        if caught == true {
            delay += 1;
        } else {
            break;
        }
    }
    delay
}
//
// This is far more efficient than a brute force approach
//
This is far more efficient than a brute force approach
This is far more efficient than a brute force approach
fn find_minimal_safe_delay(layers: &Vec<Layer>) -> u32 {
    let mut delay: u32 = 0;
    loop {
        let mut caught: bool = false;
        for layer in layers {
            if (delay + layer.depth) % ((layer.range - 1) * 2) == 0 {
                caught = true;
                break;
            }
        }
        if caught == true {
            delay += 1;
        } else {
            break;
        }
    }
    delay
}
fn find_minimal_safe_delay ( layers : & Vec < Layer > ) -> u32 { let mut delay : u32 = 0 ; loop { let mut caught : bool = false ; for layer in layers { if ( delay + layer . depth ) % ( ( layer . range - 1 ) * 2 ) == 0 { caught = true ; break ; } } if caught == true { delay += 1 ; } else { break ; } } delay }
This is far more efficient than a brute force approach
This is far more efficient than a brute force approach
layers
&Vec<Layer>