pub fn part2(lines: Vec<String>) -> u32 {
    let cols: usize = lines[0].len();

    let mut most = lines.clone();
    let mut least = most.to_vec();

    for id in 0..cols {
        let common: char = mostcommon(most.to_vec(), id);

        most = most.into_iter()
            .filter(|line| line.chars().nth(id).unwrap() == common)
            .collect::<Vec<_>>();
        if most.len() == 1 {
            break;
        }
    }

    for id in 0..cols {
        let common: char = mostcommon(least.to_vec(), id);
        least = least.into_iter()
            .filter(|line| line.chars().nth(id).unwrap() != common)
            .collect::<Vec<_>>();
        if least.len() == 1 {
            break;
        }
    }
    most.extend(least);
    most.into_iter()
        .map(|line| {
            line.chars()
                .rev()
                .enumerate()
                .map(|(index, ch)| {
                    let base: u32 = 2;
                    let exp: u32 = index.try_into().unwrap();
                    if ch == '1' {
                        base.pow(exp)
                    } else {
                        0
                    }
                })
                .sum::<u32>()
        })
        .product()
}
/* This solution is a bit ugly and needs refactoring
 * It does a lot of object copies and recursion
 */
This solution is a bit ugly and needs refactoring
It does a lot of object copies and recursion
This solution is a bit ugly and needs refactoring It does a lot of object copies and recursion
pub fn part2(lines: Vec<String>) -> u32 {
    let cols: usize = lines[0].len();
    let mut most = lines.clone();
    let mut least = most.to_vec();
    for id in 0..cols {
        let common: char = mostcommon(most.to_vec(), id);
        most = most.into_iter()
            .filter(|line| line.chars().nth(id).unwrap() == common)
            .collect::<Vec<_>>();
        if most.len() == 1 {
            break;
        }
    }
    for id in 0..cols {
        let common: char = mostcommon(least.to_vec(), id);
        least = least.into_iter()
            .filter(|line| line.chars().nth(id).unwrap() != common)
            .collect::<Vec<_>>();
        if least.len() == 1 {
            break;
        }
    }
    most.extend(least);
    most.into_iter()
        .map(|line| {
            line.chars()
                .rev()
                .enumerate()
                .map(|(index, ch)| {
                    let base: u32 = 2;
                    let exp: u32 = index.try_into().unwrap();
                    if ch == '1' {
                        base.pow(exp)
                    } else {
                        0
                    }
                })
                .sum::<u32>()
        })
        .product()
}
pub fn part2 ( lines : Vec < String > ) -> u32 { let cols : usize = lines [ 0 ] . len ( ) ; let mut most = lines . clone ( ) ; let mut least = most . to_vec ( ) ; for id in 0 .. cols { let common : char = mostcommon ( most . to_vec ( ) , id ) ; most = most . into_iter ( ) . filter ( | line | line . chars ( ) . nth ( id ) . unwrap ( ) == common ) . collect :: < Vec < _ > > ( ) ; if most . len ( ) == 1 { break ; } } for id in 0 .. cols { let common : char = mostcommon ( least . to_vec ( ) , id ) ; least = least . into_iter ( ) . filter ( | line | line . chars ( ) . nth ( id ) . unwrap ( ) != common ) . collect :: < Vec < _ > > ( ) ; if least . len ( ) == 1 { break ; } } most . extend ( least ) ; most . into_iter ( ) . map ( | line | { line . chars ( ) . rev ( ) . enumerate ( ) . map ( | ( index , ch ) | { let base : u32 = 2 ; let exp : u32 = index . try_into ( ) . unwrap ( ) ; if ch == '1' { base . pow ( exp ) } else { 0 } } ) . sum :: < u32 > ( ) } ) . product ( ) }
This solution is a bit ugly and needs refactoring
 It does a lot of object copies and recursion
This solution is a bit ugly and needs refactoring It does a lot of object copies and recursion
lines
Vec<String>
lines
Vec<String>