10 month ago I wrote my first app in Rust – Tannenbaum. I decided to make something by myself just for practice. Now I am learning Python and first app I made is Tannenbaum themselves. If you ask me what is easier Rust or Python, I wont answer. Because Rust is my first language with zero IT background. Everything was extremely difficult (today it’s just difficult). 10 month later this kind of code doesn’t look tough, I made it in a few minutes. Other issues I have to solve today: web frameworks, docker, PostgreSQL, Rust async runtime. Well… Let’s rock! Make code, not war!
use std::thread;
use std::time::Duration;
fn main() { tannenbaum(7); }
fn tannenbaum(x: i32) {
let mut top = 0;
let mut i = 1;
while top < x/2 {
for _empty_space in 0..2 { print!(" "); }
top += 1
}
if x%2 == 1 {print!(" ")}
println!("A");
while i <= x {
for _empty_space in 0..(x-i) { print!(" "); }
for _left_side in 0..i { print!("L"); }
for _middle in i..i+1 { print!("M"); }
for _right_side in 0..i { print!("R"); }
println!();
thread::sleep(Duration::from_millis(120));
i += 1
}
for _stem in 0..(x-1) { print!(" "); }
println!("ШШШ");
}
x = 8
y = 0
top = 0
i = 1
print(" " * x, end = ""), print("A")
while y < x:
if x%2 == 1:
print("|")
print("A")
print()
while i <= x:
for empty_space in range(x-i):
print(" ", end = "")
for left_side in range(i):
print("L", end = "")
for middle in range(i, i+1):
print("M", end = "")
for right_side in range(i):
print("R", end = "")
print()
i= i + 1
y = y + 1
print(" " * (x-1), end = ""), print("ШШШ")
Top comments (0)