There are two important files in this git repo:
- The tests:
tests/testthat/test-ninety_nine_beers.R
- The implementation:
R/ninety_nine_beers.R
- Install R (depending on your system, Google may be the quickest)
- In this folder, open R. Then type the command below:
> renv::restore()
To generate the lyrics of 99 bottles of beer execute the command:
$ Rscript main99.R
...
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
To generate the lyrics for a number of n bottles of beer (e.g., n=3
):
$ Rscript main_n.R 3
ℹ Loading ninetyNineBeers
The generated lyrics for n=3 are:
3 bottles of beer on the wall, 3 bottles of beer
Take one down and pass it around, 2 bottles of beer on the wall
2 bottles of beer on the wall, 2 bottles of beer
Take one down and pass it around, 1 bottle 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, 3 bottles of beer on the wall
- Open R
- In the console run:
> devtools::test()
ℹ Loading ninetyNineBeers
ℹ Testing ninetyNineBeers
✓ | F W S OK | Context
✓ | 7 | ninety_nine_beers
══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
[ FAIL 0 | WARN 0 | SKIP 0 | PASS 7 ]