Skip to content

Instantly share code, notes, and snippets.

@behdaad
Created July 14, 2020 08:49
Show Gist options
  • Save behdaad/dbb42ed381bdbcfdfb0b1684a380c21f to your computer and use it in GitHub Desktop.
Save behdaad/dbb42ed381bdbcfdfb0b1684a380c21f to your computer and use it in GitHub Desktop.
let maxBeers = 99
var beers = maxBeers
while beers >= 0 {
switch beers {
case 0:
print("No more bottles of beer on the wall, no more bottles of beer. ")
print("Go to the store and buy some more, \(maxBeers) bottles of beer on the wall.")
case 1:
print("1 bottle of beer on the wall, 1 bottle of beer.")
print("Take one down and pass it around, no more bottles of beer on the wall.")
case 2:
print("2 bottles of beer on the wall, 2 bottles of beer.")
print("Take one down and pass it around, 1 bottle of beer on the wall.")
default:
print("\(beers) bottles of beer on the wall, \(beers) bottles of beer.")
print("Take one down and pass it around, \(beers - 1) bottles of beer on the wall.")
}
beers -= 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment