Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
58
Task/SEDOLs/Langur/sedols.langur
Normal file
58
Task/SEDOLs/Langur/sedols.langur
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
val .csd = f(.code) {
|
||||
given len(.code) {
|
||||
case 0:
|
||||
return "nada, zip, zilch"
|
||||
case != 6:
|
||||
return "invalid length"
|
||||
}
|
||||
|
||||
if matching(re/[^B-DF-HJ-NP-TV-Z0-9]/, .code) {
|
||||
return "invalid character(s)"
|
||||
}
|
||||
|
||||
val .weight = [1,3,1,7,3,9]
|
||||
|
||||
val .nums = s2n .code
|
||||
val .sum = for[=0] .i of .nums {
|
||||
_for += .nums[.i] x .weight[.i]
|
||||
}
|
||||
|
||||
toString 9 - (.sum - 1) rem 10
|
||||
}
|
||||
|
||||
val .h = h{
|
||||
# invalid...
|
||||
"": 0,
|
||||
"123": 0,
|
||||
"A00030": 0,
|
||||
"E00030": 0,
|
||||
"I00030": 0,
|
||||
"O00030": 0,
|
||||
"U00030": 0,
|
||||
"β00030": 0,
|
||||
|
||||
# valid...
|
||||
"710889": 9,
|
||||
"B0YBKJ": 7,
|
||||
"406566": 3,
|
||||
"B0YBLH": 2,
|
||||
"228276": 5,
|
||||
"B0YBKL": 9,
|
||||
"557910": 7,
|
||||
"B0YBKR": 5,
|
||||
"585284": 2,
|
||||
"B0YBKT": 7,
|
||||
"B00030": 0,
|
||||
}
|
||||
|
||||
for .input in sort(keys .h) {
|
||||
val .d = .csd(.input)
|
||||
if len(.d) > 1 {
|
||||
writeln .input, ": ", .d
|
||||
} else {
|
||||
val .expect = toString .h[.input]
|
||||
write .input, .d
|
||||
writeln if .expect == .d {""} else {
|
||||
$" (SEDOL test failed; expected check digit \.expect;)"}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue