DEV Community

Discussion on: Daily Challenge #52 - Building a Pyramid

Collapse
 
brightone profile image
Oleksii Filonenko

Rust:

pub fn pyramid(floors: usize) -> String {
    (0..floors)
        .map(|f| " ".repeat(floors - f - 1) + &"*".repeat(2 * f + 1))
        .collect::<Vec<_>>()
        .join("\n")
}