Skip to content

Instantly share code, notes, and snippets.

@kamalx
Last active November 6, 2020 15:33
Show Gist options
  • Save kamalx/e0be52fd078687a877903b9976af1d2a to your computer and use it in GitHub Desktop.
Save kamalx/e0be52fd078687a877903b9976af1d2a to your computer and use it in GitHub Desktop.
99 bottles of beer on the wall (song lyrics)
String bWhat(int n) {
return n != 1 ? 'bottles' : 'bottle';
}
void main() {
for(var i = 99; i > 0; i--) {
((){
int num = i;
String b = bWhat(num);
String howManyWhat = num !=0 ? '$num ' : 'no ';
howManyWhat += '$b of beer';
print('$howManyWhat on the wall, $howManyWhat');
String doWhat = 'Take one down and pass it around';
String leftWhat = num !=1 ? '${num-1} ' : 'no ';
leftWhat += '${bWhat(num-1)} of beer on the wall.';
print('$doWhat, $leftWhat \n');
})();
}
}
@kamalx
Copy link
Author

kamalx commented Nov 6, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment