Created
July 29, 2020 10:39
-
-
Save juan-medina/042274da2eb7e513c4a5dbbbadf974de to your computer and use it in GitHub Desktop.
watter bomb kotlin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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