Created
November 9, 2018 21:15
-
-
Save andy5995/2ac487f53f8f62c9ce13d8666c6ab847 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let days = 12; | |
let rev_cumulative_day = 0; | |
let gift = [ | |
"partridge in a pear tree", | |
"turtle doves", | |
"French hens", | |
"calling birds", | |
"golden rings", | |
"geese a-layin'", | |
"swans a-swimmin'", | |
"maid a-milkin'", | |
"lords a-leapin'", | |
"ladies dancin'", | |
"pipers pipin'", | |
"drummers drummin'", | |
]; | |
let which = [ | |
"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", | |
"tenth", "eleventh", "twelfth", | |
]; | |
for day in 1..days { | |
let index = day - 1; | |
println!( | |
"On the {} day of Christmas my true love gave to me", | |
which[index] | |
); | |
if index > 0 { | |
println!("{} {}", day, gift[index]); | |
for rev_cumulative_day in (2..day).rev() { | |
println!("{} {}", rev_cumulative_day, gift[rev_cumulative_day - 1]); | |
} | |
print!("and "); | |
}; | |
println!("a {}", gift[0]); | |
println!(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment