Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
59
Task/SEDOLs/Action-/sedols.action
Normal file
59
Task/SEDOLs/Action-/sedols.action
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
INT FUNC SedolChecksum(CHAR ARRAY sedol)
|
||||
BYTE ARRAY weights=[1 3 1 7 3 9]
|
||||
INT i,sum
|
||||
CHAR c
|
||||
|
||||
IF sedol(0)#6 THEN
|
||||
RETURN (-1)
|
||||
FI
|
||||
|
||||
sum=0
|
||||
FOR i=1 TO sedol(0)
|
||||
DO
|
||||
c=sedol(i)
|
||||
IF c>='0 AND c<='9 THEN
|
||||
sum==+(c-'0)*weights(i-1)
|
||||
ELSE
|
||||
IF c>='a AND c<='z THEN
|
||||
c==-'a-'A
|
||||
FI
|
||||
IF c='A OR c='E OR c='I OR c='O OR c='U THEN
|
||||
RETURN (-1)
|
||||
ELSEIF c>='A AND c<='Z THEN
|
||||
sum==+(c-'A+10)*weights(i-1)
|
||||
ELSE
|
||||
RETURN (-1)
|
||||
FI
|
||||
FI
|
||||
OD
|
||||
sum=(10-(sum MOD 10)) MOD 10
|
||||
RETURN (sum)
|
||||
|
||||
PROC Test(CHAR ARRAY sedol)
|
||||
INT res
|
||||
|
||||
res=SedolChecksum(sedol)
|
||||
Print(sedol) Print(" -> ")
|
||||
IF res>=0 THEN
|
||||
Print(sedol) PrintIE(res)
|
||||
ELSE
|
||||
PrintE("invalid input")
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
Test("710889")
|
||||
Test("B0YBKJ")
|
||||
Test("406566")
|
||||
Test("B0YBLH")
|
||||
Test("228276")
|
||||
Test("B0YBKL")
|
||||
Test("557910")
|
||||
Test("B0YBKR")
|
||||
Test("585284")
|
||||
Test("B0YBKT")
|
||||
Test("B00030")
|
||||
Test("12345A")
|
||||
Test("12345")
|
||||
Test("1234567")
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue