Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pyramids thread

Name: Anonymous 2018-03-29 11:28

Name: Anonymous 2018-04-02 14:05

use std::env::args;
use std::iter::{once, repeat};

fn main() {
let max_depth = args()
.skip(1)
.next()
.and_then(|arg| arg.parse().ok())
.unwrap_or(8);

let out: String = (1..=max_depth)
.flat_map(|i| {
repeat(' ')
.take(max_depth - i)
.chain(repeat('*').take(i * 2 - 1))
.chain(once('\n'))
})
.collect();

print!("{}", out);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List