tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
7
Task/SEDOLs/Scala/sedols.scala
Normal file
7
Task/SEDOLs/Scala/sedols.scala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class SEDOL(s: String) {
|
||||
require(s.size == 6 || s.size == 7, "SEDOL length must be 6 or 7 characters")
|
||||
require(s.size == 6 || s(6).asDigit == chksum, "Incorrect SEDOL checksum")
|
||||
require(s forall (c => !("aeiou" contains c.toLower)), "Vowels not allowed in SEDOL")
|
||||
def chksum = 10 - ((s zip List(1, 3, 1, 7, 3, 9) map { case (c, w) => c.asDigit * w } sum) % 10)
|
||||
override def toString = s.take(6) + chksum
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue