object BeerSong {
    val lyrics: String by lazy {
        verses(99, 0)
    }
    fun verse(verseNumber: Int): String{
        if (verseNumber < 0 || verseNumber > 99) throw IllegalArgumentException()
        when (verseNumber){
            0 -> return "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
            1 -> return "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"
            2 -> return "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"
            else -> return "${verseNumber} bottles of beer on the wall, ${verseNumber} bottles of beer.\nTake one down and pass it around, ${verseNumber -1} bottles of beer on the wall.\n"
        }
    }

    fun verses(firstVerse: Int, lastVerse: Int): String{
        return (IntRange(lastVerse, firstVerse).reversed()).map { verse(it) }.fold("", {acc, s -> acc + s + "\n" }).dropLast(1)
    }
}