Created
June 1, 2018 09:44
-
-
Save dcampogiani/94d321cd80dc6af53ba5e5f100912521 to your computer and use it in GitHub Desktop.
This file contains 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
fun fizzBuzz(input: Int, entryList: List<Entry>): String { | |
val filtered = entryList.filter { input isMultipleOf it.value } | |
return if (filtered.isEmpty()) { | |
input.toString() | |
} else { | |
filtered.joinToString(separator = "") { it.decorateString } | |
} | |
} | |
infix fun Int.isMultipleOf(other: Int) = this.rem(other) == 0 | |
val entryList = listOf( | |
Entry(3, "fizz"), | |
Entry(5, "buzz"), | |
Entry(7, "pazz")) | |
data class Entry(val value: Int, val decorateString: String) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment