Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
35
Task/SEDOLs/Pluto/sedols.pluto
Normal file
35
Task/SEDOLs/Pluto/sedols.pluto
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
local function sedol(s)
|
||||
if not(type(s) == "string" and #s == 6) then return false end
|
||||
local weights = {1, 3, 1, 7, 3, 9}
|
||||
local sum = 0
|
||||
for i = 1, 6 do
|
||||
local c = s[i]
|
||||
if not c:isupper() and not(c in "0123456789") then
|
||||
return nil
|
||||
end
|
||||
if c in "AEIOU" then return nil end
|
||||
sum += tonumber(c, 36) * weights[i]
|
||||
end
|
||||
local cd = (10 - sum % 10) % 10
|
||||
return s .. $"{cd}"
|
||||
end
|
||||
|
||||
local tests = {
|
||||
"710889",
|
||||
"B0YBKJ",
|
||||
"406566",
|
||||
"B0YBLH",
|
||||
"228276",
|
||||
"B0YBKL",
|
||||
"557910",
|
||||
"B0YBKR",
|
||||
"585284",
|
||||
"B0YBKT",
|
||||
"B00030",
|
||||
"I23456"
|
||||
}
|
||||
|
||||
for tests as test do
|
||||
local ans = sedol(test) ?? "not valid"
|
||||
print($"{test} -> {ans}")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue