loading...

re: Challenge - Print Spiral VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Got it to Level 2, without using arrays at all. On level 2 this becomes purely a math problem, so its solutions will be probably pretty similar in ...
 

If you want to use it in the stable channel, just change the main() to

fn main() {
    let border = (SPIRAL_SIDE / 2) as i32;
    let (min, max) = if SPIRAL_SIDE % 2 == 0 {
        (-border + 1, border + 1)
    } else {
        (-border, border)
    };

    for y in (min..max).rev() {
        (min..max)
            .into_iter()
            .for_each(|x| print!("{:>3} ", number_at(x, y)));
        println!();
    }
}

And no need of

#![feature(inclusive_range_syntax)]
Code of Conduct Report abuse