Sha256: 50633b8a1806c921f782db3ad34cce8dd1b13cd6d007b08bf09ddcf726e6db09

Contents?: true

Size: 881 Bytes

Versions: 116

Compression:

Stored size: 881 Bytes

Contents

object BeerSong {

    fun verses(startBottles: Int, takeDown: Int) = (startBottles downTo takeDown).joinToString("\n") { verse(it) }

    private fun verse(number: Int) = when (number) {
        0 -> "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 -> "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 -> "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"
        in 3..99 -> "$number bottles of beer on the wall, $number bottles of beer.\nTake one down and pass it around, ${number - 1} bottles of beer on the wall.\n"
        else -> throw IllegalArgumentException("Invalid verse number: $number, must be within 0 and 99")
    }

}

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.138 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.137 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.136 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.135 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.134 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.133 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.132 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.131 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.130 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.129 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.128 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.127 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.126 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.125 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.124 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.123 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.122 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.121 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt
trackler-2.2.1.120 tracks/kotlin/exercises/beer-song/.meta/src/reference/kotlin/BeerSong.kt