I explicitly mutated the rows in the second half, it made the formulae a bit less messy
for mut y in 0..(width-1) {
if y > (width-2)/2 {
y = width-2-y
}
for x in 0..width {
match (x, y) {
(x, y) if x*y==0 || // assume no overflow
x==y ||
y==width-1-x ||
x==width-1 => print!("#"),
_ => print!(" ")
}
}
print!("\n");
}
View all comments
Show parent comment
12
u/etoastie 2d ago
Can simplify the middle two a tad by reflecting the lines at the middle, instead of trying to model the diagonal with the offset