Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
10
Task/SEDOLs/Groovy/sedols-1.groovy
Normal file
10
Task/SEDOLs/Groovy/sedols-1.groovy
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def checksum(text) {
|
||||
assert text.size() == 6 && !text.toUpperCase().find(/[AEIOU]+/) : "Invalid SEDOL text: $text"
|
||||
|
||||
def sum = 0
|
||||
(0..5).each { index ->
|
||||
sum += Character.digit(text.charAt(index), 36) * [1, 3, 1, 7, 3, 9][index]
|
||||
}
|
||||
text + (10 - (sum % 10)) % 10
|
||||
}
|
||||
String.metaClass.sedol = { this.&checksum(delegate) }
|
||||
6
Task/SEDOLs/Groovy/sedols-2.groovy
Normal file
6
Task/SEDOLs/Groovy/sedols-2.groovy
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[ '710889': '7108899', 'B0YBKJ': 'B0YBKJ7', '406566': '4065663', 'B0YBLH': 'B0YBLH2',
|
||||
'228276': '2282765', 'B0YBKL': 'B0YBKL9', '557910': '5579107', 'B0YBKR': 'B0YBKR5',
|
||||
'585284': '5852842', 'B0YBKT': 'B0YBKT7', 'B00030': 'B000300'].each { text, expected ->
|
||||
println "Checking $text -> $expected"
|
||||
assert expected == text.sedol()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue