pub fn play(boards: &mut [Board], draws: &[usize]) -> ((usize, usize), (usize, usize)) {
    // vector of tuples of board and draw indices
    let results: Vec<_> = boards
        .iter_mut()
        .map(|board| board.apply_draws(&draws).expect("Board never wins"))
        .enumerate()
        .collect();

    // find winner
    let (winner_board_idx, winner_draw_idx) = results
        .iter()
        .min_by(|(_, idx_a), (_, idx_b)| idx_a.cmp(idx_b))
        .expect("No winner");
    // find looser
    let (looser_board_idx, looser_draw_idx) = results
        .iter()
        .max_by(|(_, idx_a), (_, idx_b)| idx_a.cmp(idx_b))
        .expect("No looser");

    (
        (*winner_board_idx, draws[*winner_draw_idx]),
        (*looser_board_idx, draws[*looser_draw_idx]),
    )
}
//tag::play[]
/// play bingo
///
/// returns a two tuples of a board index and the last number drawn for the board which wins first
/// and the board which wins last
:play[]
play bingo

returns a two tuples of a board index and the last number drawn for the board which wins first
and the board which wins last
: play [] play bingo returns a two tuples of a board index and the last number drawn for the board which wins first and the board which wins last
pub fn play(boards: &mut [Board], draws: &[usize]) -> ((usize, usize), (usize, usize)) {
    // vector of tuples of board and draw indices
    let results: Vec<_> = boards
        .iter_mut()
        .map(|board| board.apply_draws(&draws).expect("Board never wins"))
        .enumerate()
        .collect();
    // find winner
    let (winner_board_idx, winner_draw_idx) = results
        .iter()
        .min_by(|(_, idx_a), (_, idx_b)| idx_a.cmp(idx_b))
        .expect("No winner");
    // find looser
    let (looser_board_idx, looser_draw_idx) = results
        .iter()
        .max_by(|(_, idx_a), (_, idx_b)| idx_a.cmp(idx_b))
        .expect("No looser");
    (
        (*winner_board_idx, draws[*winner_draw_idx]),
        (*looser_board_idx, draws[*looser_draw_idx]),
    )
}
pub fn play ( boards : & mut [ Board ] , draws : & [ usize ] ) -> ( ( usize , usize ) , ( usize , usize ) ) { // vector of tuples of board and draw indices let results : Vec < _ > = boards . iter_mut ( ) . map ( | board | board . apply_draws ( & draws ) . expect ( " " ) ) . enumerate ( ) . collect ( ) ; // find winner let ( winner_board_idx , winner_draw_idx ) = results . iter ( ) . min_by ( | ( _ , idx_a ) , ( _ , idx_b ) | idx_a . cmp ( idx_b ) ) . expect ( " " ) ; // find looser let ( looser_board_idx , looser_draw_idx ) = results . iter ( ) . max_by ( | ( _ , idx_a ) , ( _ , idx_b ) | idx_a . cmp ( idx_b ) ) . expect ( " " ) ; ( ( * winner_board_idx , draws [ * winner_draw_idx ] ) , ( * looser_board_idx , draws [ * looser_draw_idx ] ) , ) }
tag::play[]
play bingo
tag :: play [] play bingo
boards
&mut [Board]
draws
&[usize]
boards
&mut [Board]
draws
&[usize]