Skip to content

Instantly share code, notes, and snippets.

@juan-medina
Created July 29, 2020 10:39
Show Gist options
  • Select an option

  • Save juan-medina/042274da2eb7e513c4a5dbbbadf974de to your computer and use it in GitHub Desktop.

Select an option

Save juan-medina/042274da2eb7e513c4a5dbbbadf974de to your computer and use it in GitHub Desktop.
watter bomb kotlin
import kotlin.math.ceil
infix fun String.watterBomb(size: Int) = this.split("Y").map{
ceil(it.length / size.toDouble()).toInt()
}.sum()
fun main() {
println("xxYxx" watterBomb 3 == 2)
println("xxYxx" watterBomb 1 == 4)
println("xxxxYxYx" watterBomb 5 == 3)
println("xxxxxYxYx" watterBomb 2 == 5)
println("xxxxYxYx" watterBomb 4 == 3)
println("xxYxx" watterBomb 3 == 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment