-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathascii-worms.rs
More file actions
22 lines (19 loc) · 1.12 KB
/
ascii-worms.rs
File metadata and controls
22 lines (19 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::io;
macro_rules! parse_input {
($t:ident) => {{
let mut input_line = String::new();
io::stdin().read_line(&mut input_line).unwrap();
input_line.trim_matches('\n').parse::<$t>().unwrap()
}}
}
fn main() {
let thickness = parse_input!(usize);
let length = parse_input!(usize);
let turns = parse_input!(usize);
println!(" {}{}{}", "_".repeat(thickness), (" ".to_owned() + "_".repeat(thickness*2+1).as_str()).repeat(turns / 2), (if turns % 2 == 1{" ".to_owned() + "_".repeat(thickness).as_str()} else {"".to_string()}));
println!("|{}{}{}|", " ".repeat(thickness), ("|".to_owned() + " ".repeat(thickness*2+1).as_str()).repeat(turns / 2), (if turns % 2 == 1{"|".to_owned() + " ".repeat(thickness).as_str()} else {"".to_string()}));
for _ in 2..length {
println!("{}|", ("|".to_owned() + " ".repeat(thickness).as_str()).repeat(turns+1));
}
println!("{}{}{}", ("|".to_owned() + "_".repeat(thickness*2+1).as_str()).repeat(turns / 2), (if turns % 2 == 0{"|".to_owned() + "_".repeat(thickness).as_str()} else {"|".to_owned() + "_".repeat(thickness*2+1).as_str()}), "|");
}