fn normalize_sol(sol: &mut [i32], simplify: bool) {
    if simplify {
        let gcd = sol.iter().copied().reduce(gcd).unwrap();
        if gcd != 1 {
            sol.iter_mut().for_each(|n| *n /= gcd);
        }
    }

    let neg = match sol.iter().map(|n| n.signum()).sum() {
        0 => sol.iter().copied().find(|&n| n != 0).unwrap(),
        sum => sum,
    };
    if neg < 0 {
        sol.iter_mut().for_each(|n| *n = -*n);
    }
}
/// Normalizes a solution, with simplification if needed.
///
/// A normalized solution is one where the number of positive coefficients
/// is greater than that of negative ones or, if the numbers are equal,
/// the first nonzero coefficient is positive.
Normalizes a solution, with simplification if needed.
A normalized solution is one where the number of positive coefficients
is greater than that of negative ones or, if the numbers are equal,
the first nonzero coefficient is positive.
Normalizes a solution with simplification if needed . A normalized solution is one where the number of positive coefficients is greater than that of negative ones or if the numbers are equal the first nonzero coefficient is positive .
fn normalize_sol(sol: &mut [i32], simplify: bool) {
    if simplify {
        let gcd = sol.iter().copied().reduce(gcd).unwrap();
        if gcd != 1 {
            sol.iter_mut().for_each(|n| *n /= gcd);
        }
    }
    let neg = match sol.iter().map(|n| n.signum()).sum() {
        0 => sol.iter().copied().find(|&n| n != 0).unwrap(),
        sum => sum,
    };
    if neg < 0 {
        sol.iter_mut().for_each(|n| *n = -*n);
    }
}
fn normalize_sol ( sol : & mut [ i32 ] , simplify : bool ) { if simplify { let gcd = sol . iter ( ) . copied ( ) . reduce ( gcd ) . unwrap ( ) ; if gcd != 1 { sol . iter_mut ( ) . for_each ( | n | * n /= gcd ) ; } } let neg = match sol . iter ( ) . map ( | n | n . signum ( ) ) . sum ( ) { 0 => sol . iter ( ) . copied ( ) . find ( | & n | n != 0 ) . unwrap ( ) , sum => sum , } ; if neg < 0 { sol . iter_mut ( ) . for_each ( | n | * n = - * n ) ; } }
Normalizes a solution, with simplification if needed.
Normalizes a solution with simplification if needed .
sol
&mut [i32]
simplify
bool
sol
&mut [i32]
simplify
bool