SEDOLs: Difference between revisions

65 bytes removed ,  1 month ago
m
(→‎{{header|Kotlin}}: Make Kotlin solution more succinct using modern library features)
Line 2,373:
 
fun sedol7(sedol6: String): String {
if require(sedol6.length !== 6) { "Length of argument string must be 6" }
require(sedol6.all { it in throwvalidChars }) { IllegalArgumentException("Argument string contains an invalid character") }
throw IllegalArgumentException("Length of argument string must be 6")
if (sedol6.any { it !in validChars })
throw IllegalArgumentException("Argument string contains an invalid character")
 
val sum = sedol6.map { it.digitToInt(36) }.zip(weights, Int::times).sum()
47

edits