Add twelve days of christmas
This commit is contained in:
parent
5d14e86f4a
commit
30649df52e
2 changed files with 80 additions and 0 deletions
9
twelve_days_of_christmas/Cargo.toml
Normal file
9
twelve_days_of_christmas/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "twelve_days_of_christmas"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["laurens <miers132@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
71
twelve_days_of_christmas/src/main.rs
Normal file
71
twelve_days_of_christmas/src/main.rs
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
struct ChristmasDay {
|
||||||
|
day: String,
|
||||||
|
gift: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let christmas_days: [ChristmasDay; 12] = [
|
||||||
|
ChristmasDay {
|
||||||
|
day: "first".to_string(),
|
||||||
|
gift: "a Partridge in a Pear Tree".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "second".to_string(),
|
||||||
|
gift: "Two Turtle Doves".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "third".to_string(),
|
||||||
|
gift: "Three French Hens".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "fourth".to_string(),
|
||||||
|
gift: "Four Calling Birds".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "fifth".to_string(),
|
||||||
|
gift: "Five Goldon Rings".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "sixth".to_string(),
|
||||||
|
gift: "Six Geese a Laying".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "seventh".to_string(),
|
||||||
|
gift: "Sevens Swans a Swimming".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "eigth".to_string(),
|
||||||
|
gift: "Eight Maids a Milking".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "ninth".to_string(),
|
||||||
|
gift: "Nine Ladies Dancing".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "tenth".to_string(),
|
||||||
|
gift: "Ten Lords a Leaping".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "eleventh".to_string(),
|
||||||
|
gift: "Eleven Pipers Piping".to_string(),
|
||||||
|
},
|
||||||
|
ChristmasDay {
|
||||||
|
day: "twelfth".to_string(),
|
||||||
|
gift: "12 Drummers Drumming".to_string(),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
for (i, elem) in christmas_days.iter().enumerate() {
|
||||||
|
println!();
|
||||||
|
println!(
|
||||||
|
"On the {} day of Christmas, my true love sent to me:",
|
||||||
|
elem.day
|
||||||
|
);
|
||||||
|
for j in (0..i + 1).rev() {
|
||||||
|
if j == 0 && i > 0 {
|
||||||
|
print!("And ");
|
||||||
|
}
|
||||||
|
println!("{}", christmas_days[j].gift);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue