WIP for more generic
[?]
Jul 5, 2020, 8:32 PM
2USDM5CH2K26B4DB5YEMVIT43NLY5PNQJZHW2HK2COXQZ75QTLOACDependencies
- [2]
F3GMCMWTMerge branch 'master' into sovrum - [3]
5TH3AA4610 mm extra space - [4]
UPCMFGXFPrint more about the room and define PLAY - [5]
RXRHPE7SSovrummet - [6]
3H2BGWRGWIP
Change contents
- replacement in src/main.rs at line 1
static PLANKMAX: i32 = 2200;static PLANKWIDTH: i32 = 185;static PLAY: i32 = 20;static ROOMLENGTH: i32 = 3800 - PLAY;static ROOMDEPTH: i32 = 2800 - PLAY;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
// Define a plank structure#[derive(Debug)]struct Plank {length: u32,endpiece: bool,} - replacement in src/main.rs at line 18
println!("Room dimensions: {} x {} mm", ROOMLENGTH + PLAY, ROOMDEPTH + PLAY);println!("Room dimensions: {} x {} mm",ROOMLENGTH + PLAY,ROOMDEPTH + PLAY); - replacement in src/main.rs at line 25
let mut temp = 0;let mut leftover = 0; - replacement in src/main.rs at line 28
let mut planklist = vec![];let mut rowlist: Vec<Vec<Plank>> = vec![]; - replacement in src/main.rs at line 30
temp = calc_new_length(PLANKMAX, ROOMLENGTH - temp);//println!("First plank length: {}", PLANKMAX - leftover); - replacement in src/main.rs at line 32
println!("First plank length: {}", PLANKMAX - temp);while coverage < ROOMDEPTH {// Create new plank vectorlet mut row = vec![]; - replacement in src/main.rs at line 36
while coverage < ROOMDEPTH {// Store the old length for the listlet tempold = temp;let mut rowfilled = 0;while rowfilled < ROOMLENGTH {// Length of the plank is greater than the remainder roomif ROOMLENGTH - rowfilled > PLANKMAX {// If this is the first planklet end = rowfilled == 0;// Store the full length plankrow.push(Plank {length: PLANKMAX,endpiece: end,});rowfilled += PLANKMAX; - replacement in src/main.rs at line 49
// Length of the plank is greater than the roomif temp > ROOMLENGTH {// For each iteration, we have used another plankplankcount += 1; - replacement in src/main.rs at line 52
// Store the full length plank and the nextplanklist.push((ROOMLENGTH, 0));// If a whole plank was used, the leftover is 0leftover = 0; - replacement in src/main.rs at line 55
temp -= ROOMLENGTH;// Length of the plank is smaller than the room} else {// Store the two plank lengths as a tupleplanklist.push((tempold, ROOMLENGTH - temp));// Length of the plank is smaller than the room} else {// Add the remainderlet remainder = ROOMLENGTH - rowfilled;row.push(Plank {length: remainder,endpiece: true,});rowfilled += remainder; - replacement in src/main.rs at line 65
// Calculate the next plank lengthtemp = calc_new_length(PLANKMAX, ROOMLENGTH - temp);// Calculate the leftover plank lengthleftover = PLANKMAX - (ROOMLENGTH - rowfilled);} - edit in src/main.rs at line 69
let mut leftoverold = leftover; - edit in src/main.rs at line 71
rowlist.push(row); - edit in src/main.rs at line 75
// For each iteration, we have added another plankplankcount += 1; - edit in src/main.rs at line 77
println!("\n: {:#?}\n", rowlist); - edit in src/main.rs at line 79
/* - edit in src/main.rs at line 96
*/ - replacement in src/main.rs at line 99
fn calc_new_length(prev: i32, next: i32) -> i32 {fn calc_new_length(prev: u32, next: u32) -> u32 {