pub fn raise(p: Problem) -> Solution {
    // initialize collector
    let collector0 = Collector::new(p.groundsize);

    let recursor_pars = RecursorPars::new(p.water_tot as f64, 0, p.groundsize - 1, 0, 0, 0);
    let collector = recursor(recursor_pars, &p.grounds, collector0);

    let Collector { segments } = collector;

    let levels: Vec<f64> = segments.iter().map(|s| *s).collect();

    // calculate the water levels in reverse, starting left going right
    let rev_pars = RecursorPars::new(p.water_tot as f64, 0, p.groundsize - 1, 0, 0, 0);
    let rev_grounds: Vec<u64> = p.grounds.clone().iter().rev().map(|a| *a).collect();
    let rev_coll0 = Collector::new(p.groundsize);
    let rev_collector = recursor(rev_pars, &rev_grounds, rev_coll0);

    // then average results of both calculations
    let average_levels: Vec<f64> = rev_collector
        .segments
        .iter()
        .rev()
        .zip(levels)
        .map(|(a, b)| (a + b) / 2.0)
        .collect();
    return Solution::new(average_levels, &p.grounds);
}
// raise initialises and calls the recursion function and pieces results together
raise initialises and calls the recursion function and pieces results together
raise initialises and calls the recursion function and pieces results together
pub fn raise(p: Problem) -> Solution {
    // initialize collector
    let collector0 = Collector::new(p.groundsize);
    let recursor_pars = RecursorPars::new(p.water_tot as f64, 0, p.groundsize - 1, 0, 0, 0);
    let collector = recursor(recursor_pars, &p.grounds, collector0);
    let Collector { segments } = collector;
    let levels: Vec<f64> = segments.iter().map(|s| *s).collect();
    // calculate the water levels in reverse, starting left going right
    let rev_pars = RecursorPars::new(p.water_tot as f64, 0, p.groundsize - 1, 0, 0, 0);
    let rev_grounds: Vec<u64> = p.grounds.clone().iter().rev().map(|a| *a).collect();
    let rev_coll0 = Collector::new(p.groundsize);
    let rev_collector = recursor(rev_pars, &rev_grounds, rev_coll0);
    // then average results of both calculations
    let average_levels: Vec<f64> = rev_collector
        .segments
        .iter()
        .rev()
        .zip(levels)
        .map(|(a, b)| (a + b) / 2.0)
        .collect();
    return Solution::new(average_levels, &p.grounds);
}
pub fn raise ( p : Problem ) -> Solution { // initialize collector let collector0 = Collector :: new ( p . groundsize ) ; let recursor_pars = RecursorPars :: new ( p . water_tot as f64 , 0 , p . groundsize - 1 , 0 , 0 , 0 ) ; let collector = recursor ( recursor_pars , & p . grounds , collector0 ) ; let Collector { segments } = collector ; let levels : Vec < f64 > = segments . iter ( ) . map ( | s | * s ) . collect ( ) ; // calculate the water levels in reverse, starting left going right let rev_pars = RecursorPars :: new ( p . water_tot as f64 , 0 , p . groundsize - 1 , 0 , 0 , 0 ) ; let rev_grounds : Vec < u64 > = p . grounds . clone ( ) . iter ( ) . rev ( ) . map ( | a | * a ) . collect ( ) ; let rev_coll0 = Collector :: new ( p . groundsize ) ; let rev_collector = recursor ( rev_pars , & rev_grounds , rev_coll0 ) ; // then average results of both calculations let average_levels : Vec < f64 > = rev_collector . segments . iter ( ) . rev ( ) . zip ( levels ) . map ( | ( a , b ) | ( a + b ) / 2.0 ) . collect ( ) ; return Solution :: new ( average_levels , & p . grounds ) ; }
raise initialises and calls the recursion function and pieces results together
raise initialises and calls the recursion function and pieces results together
p
Problem
p
Problem