fn bin_search(min: usize, max: usize, words: &Vec<usize>, terminal_width: usize) -> usize {
        let diff = min as isize - max as isize;
        let fits = try_rows(words, min + (max - min) / 2, terminal_width);
        if  diff == -1 || diff == 0 || diff == 1{
            return min;
        } else if fits {
            return bin_search(min + (max - min) / 2, max, words, terminal_width);
        } else {
            return bin_search(min, min + (max - min) / 2, words, terminal_width);
        }
    }
/// Binary search to find the perfect amounth of columns efficiently
Binary search to find the perfect amounth of columns efficiently
Binary search to find the perfect amounth of columns efficiently
fn bin_search(min: usize, max: usize, words: &Vec<usize>, terminal_width: usize) -> usize {
        let diff = min as isize - max as isize;
        let fits = try_rows(words, min + (max - min) / 2, terminal_width);
        if  diff == -1 || diff == 0 || diff == 1{
            return min;
        } else if fits {
            return bin_search(min + (max - min) / 2, max, words, terminal_width);
        } else {
            return bin_search(min, min + (max - min) / 2, words, terminal_width);
        }
    }
fn bin_search ( min : usize , max : usize , words : & Vec < usize > , terminal_width : usize ) -> usize { let diff = min as isize - max as isize ; let fits = try_rows ( words , min + ( max - min ) / 2 , terminal_width ) ; if diff == - 1 || diff == 0 || diff == 1 { return min ; } else if fits { return bin_search ( min + ( max - min ) / 2 , max , words , terminal_width ) ; } else { return bin_search ( min , min + ( max - min ) / 2 , words , terminal_width ) ; } }
Binary search to find the perfect amounth of columns efficiently
Binary search to find the perfect amounth of columns efficiently
min
usize
max
usize
words
&Vec<usize>
terminal_width
usize