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5WGVYUWC7IDXN3D3HMBC6RBA7QC
ZP2CTPQICUHU3UZJFM6TPKTGYCD2ACLVDYIW33PUDAEMER4DIL7QC
}
}
impl Display for Floor {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let scalefactor = 50;
for (num, row) in self.rows().iter().enumerate() {
// Try to compensate for the extra size taken by
// the number printout
let comp = 50 * row.planks_count();
let mut length_sum = 0;
write!(f, " ")?; // Prefix space for play
for plank in row.planks().iter() {
length_sum += plank.length;
write!(f, "|")?;
// Print the relative length of the plank
for _ in 0..((plank.length()) / scalefactor) {
write!(f, "-")?;
}
}
write!(f, "|")?;
write!(f, " Cut coordinates: ")?;
for cut in row.get_cut_coordinates() {
write!(f, " {cut: ^6}, ")?;
}
writeln!(f)?;
write!(f, "+{PLAY}")?;
for plank in row.planks().iter() {
for _ in 0..((plank.length() - comp) / scalefactor) / 2 {
write!(f, " ")?;
}
// Print the numeric length
write!(f, "{: ^6}", plank.length())?;
// Remainder of the plank
for _ in 0..((plank.length() - comp) / scalefactor) / 2 {
write!(f, " ")?;
}
}
write!(f, "+{PLAY}")?;
writeln!(f, "\t Row length: {length_sum}\trow: {:#?}", num + 1)?;
write!(f, " ")?; // Prefix space for play
for plank in row.planks().iter() {
write!(f, "|")?;
// Print the bottom row of the plank
for _ in 0..(plank.length() / scalefactor) {
write!(f, "-")?;
}
}
writeln!(f, "|")?;
writeln!(f)?;
}
Ok(())
floor_print(&floor, &ms);
println!("Number of leftover cut planks: {}", ms.get_used_count());
}
fn floor_print(floor: &Floor, ms: &MaterialStorage) {
let scalefactor = 50;
for (num, row) in floor.rows().iter().enumerate() {
// Try to compensate for the extra size taken by
// the number printout
let comp = 50 * row.planks_count();
let mut length_sum = 0;
print!(" "); // Prefix space for play
for plank in row.planks().iter() {
length_sum += plank.length;
print!("|");
// Print the relative length of the plank
for _ in 0..((plank.length()) / scalefactor) {
print!("-");
}
}
print!("|");
print!(" Cut coordinates: ");
for cut in row.get_cut_coordinates() {
print!(" {cut: ^6}, ");
}
println!();
print!("+{PLAY}");
for plank in row.planks().iter() {
for _ in 0..((plank.length() - comp) / scalefactor) / 2 {
print!(" ");
}
// Print the numeric length
print!("{: ^6}", plank.length());
// Remainder of the plank
for _ in 0..((plank.length() - comp) / scalefactor) / 2 {
print!(" ");
}
}
print!("+{PLAY}");
println!("\t Row length: {length_sum}\trow: {:#?}", num + 1);
print!(" "); // Prefix space for play
for plank in row.planks().iter() {
print!("|");
// Print the bottom row of the plank
for _ in 0..(plank.length() / scalefactor) {
print!("-");
}
}
println!("|");
println!();
}
println!();
println!("{floor}");