Last active
April 14, 2016 13:24
-
-
Save Pre1/282a22d2f831da65788e953d75f1a8e5 to your computer and use it in GitHub Desktop.
99 bottles of beer in swift 2.2...3.0
This file contains 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
/* | |
99 bottles of beer on the wall, 99 bottles of beer. | |
Take one down and pass it around, 98 bottles of beer on the wall. | |
. | |
. | |
. | |
1 bottle of beer on the wall, 1 bottle of beer. | |
Take one down and pass it around, no more bottles of beer on the wall. | |
No more bottles of beer on the wall, no more bottles of beer. | |
Go to the store and buy some more, 99 bottles of beer on the wall. | |
*/ | |
let (beers, wall, take, end) = ("bottles of beer", " on the wall", | |
"Take one down and pass it around,", | |
"Go to the store and buy some more,") | |
for i in (0...99).reverse() { | |
print( | |
"\(i == 0 ? "No more" : "\(i)") \(beers + wall),", | |
"\(i == 0 ? "no more" : "\(i)") \(beers).\n", | |
"\(i == 0 ? end : take)", | |
"\(i-1 == 0 ? "no more" : "\(i == 0 ? "\(i+99)" : "\(i-1)") ") \(beers + wall).\n" | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment