WIP for more generic

[?]
Jul 5, 2020, 8:32 PM
2USDM5CH2K26B4DB5YEMVIT43NLY5PNQJZHW2HK2COXQZ75QTLOAC

Dependencies

Change contents

  • replacement in src/main.rs at line 1
    [3.1][3.2:61](),[3.61][3.0:23](),[3.23][2.0:75]()
    static PLANKMAX: i32 = 2200;
    static PLANKWIDTH: i32 = 185;
    static PLAY: i32 = 20;
    static ROOMLENGTH: i32 = 3800 - PLAY;
    static ROOMDEPTH: i32 = 2800 - PLAY;
    [3.1]
    [3.132]
    static PLANKMAX: u32 = 2200;
    static PLANKWIDTH: u32 = 185;
    static PLAY: u32 = 20;
    static ROOMLENGTH: u32 = 3800;
    static ROOMDEPTH: u32 = 2800;
    // TODO Add PLAY at the end when printing
  • edit in src/main.rs at line 8
    [3.133]
    [3.133]
    // Define a plank structure
    #[derive(Debug)]
    struct Plank {
    length: u32,
    endpiece: bool,
    }
  • replacement in src/main.rs at line 18
    [3.100][3.100:182]()
    println!("Room dimensions: {} x {} mm", ROOMLENGTH + PLAY, ROOMDEPTH + PLAY);
    [3.100]
    [3.182]
    println!(
    "Room dimensions: {} x {} mm",
    ROOMLENGTH + PLAY,
    ROOMDEPTH + PLAY
    );
  • replacement in src/main.rs at line 25
    [3.187][3.187:209]()
    let mut temp = 0;
    [3.187]
    [3.62]
    let mut leftover = 0;
  • replacement in src/main.rs at line 28
    [3.116][3.264:296](),[3.264][3.264:296]()
    let mut planklist = vec![];
    [3.116]
    [3.296]
    let mut rowlist: Vec<Vec<Plank>> = vec![];
  • replacement in src/main.rs at line 30
    [3.297][2.76:133]()
    temp = calc_new_length(PLANKMAX, ROOMLENGTH - temp);
    [3.297]
    [3.354]
    //println!("First plank length: {}", PLANKMAX - leftover);
  • replacement in src/main.rs at line 32
    [3.355][2.134:191]()
    println!("First plank length: {}", PLANKMAX - temp);
    [3.355]
    [3.449]
    while coverage < ROOMDEPTH {
    // Create new plank vector
    let mut row = vec![];
  • replacement in src/main.rs at line 36
    [3.450][3.450:556]()
    while coverage < ROOMDEPTH {
    // Store the old length for the list
    let tempold = temp;
    [3.450]
    [3.556]
    let mut rowfilled = 0;
    while rowfilled < ROOMLENGTH {
    // Length of the plank is greater than the remainder room
    if ROOMLENGTH - rowfilled > PLANKMAX {
    // If this is the first plank
    let end = rowfilled == 0;
    // Store the full length plank
    row.push(Plank {
    length: PLANKMAX,
    endpiece: end,
    });
    rowfilled += PLANKMAX;
  • replacement in src/main.rs at line 49
    [3.557][3.557:644]()
    // Length of the plank is greater than the room
    if temp > ROOMLENGTH {
    [3.557]
    [3.644]
    // For each iteration, we have used another plank
    plankcount += 1;
  • replacement in src/main.rs at line 52
    [3.645][3.645:746]()
    // Store the full length plank and the next
    planklist.push((ROOMLENGTH, 0));
    [3.645]
    [3.746]
    // If a whole plank was used, the leftover is 0
    leftover = 0;
  • replacement in src/main.rs at line 55
    [3.747][3.747:964]()
    temp -= ROOMLENGTH;
    // Length of the plank is smaller than the room
    } else {
    // Store the two plank lengths as a tuple
    planklist.push((tempold, ROOMLENGTH - temp));
    [3.747]
    [3.964]
    // Length of the plank is smaller than the room
    } else {
    // Add the remainder
    let remainder = ROOMLENGTH - rowfilled;
    row.push(Plank {
    length: remainder,
    endpiece: true,
    });
    rowfilled += remainder;
  • replacement in src/main.rs at line 65
    [3.965][3.965:1077]()
    // Calculate the next plank length
    temp = calc_new_length(PLANKMAX, ROOMLENGTH - temp);
    [3.965]
    [3.1077]
    // Calculate the leftover plank length
    leftover = PLANKMAX - (ROOMLENGTH - rowfilled);
    }
  • edit in src/main.rs at line 69
    [3.1078]
    [3.1078]
    let mut leftoverold = leftover;
  • edit in src/main.rs at line 71
    [3.1088]
    [3.1088]
    rowlist.push(row);
  • edit in src/main.rs at line 75
    [3.1173][3.1173:1257]()
    // For each iteration, we have added another plank
    plankcount += 1;
  • edit in src/main.rs at line 77
    [3.1323]
    [3.1323]
    println!("\n: {:#?}\n", rowlist);
  • edit in src/main.rs at line 79
    [3.1324]
    [3.1324]
    /*
  • edit in src/main.rs at line 96
    [3.1923]
    [3.1923]
    */
  • replacement in src/main.rs at line 99
    [3.1926][3.1926:1976]()
    fn calc_new_length(prev: i32, next: i32) -> i32 {
    [3.1926]
    [3.1976]
    fn calc_new_length(prev: u32, next: u32) -> u32 {