Sha256: 6e751e2fcbe2c263fae608a2cd9728e1137476942df223160df5ef225f9aa9b9

Contents?: true

Size: 275 Bytes

Versions: 396

Compression:

Stored size: 275 Bytes

Contents

class Squares(private val max: Int) {
    private val range = 1..max

    fun sumOfSquares() = range.map { it.squared() }.sum()
    fun squareOfSum() = range.sum().squared()
    fun difference() = squareOfSum() - sumOfSquares()

    private fun Int.squared() = this * this
}

Version data entries

396 entries across 396 versions & 1 rubygems

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