Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
36
Task/CUSIP/11l/cusip.11l
Normal file
36
Task/CUSIP/11l/cusip.11l
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
F cusip_check(=cusip)
|
||||
I cusip.len != 9
|
||||
X ValueError(‘CUSIP must be 9 characters’)
|
||||
|
||||
cusip = cusip.uppercase()
|
||||
V total = 0
|
||||
L(i) 8
|
||||
V v = 0
|
||||
V c = cusip[i]
|
||||
I c.is_digit()
|
||||
v = Int(c)
|
||||
E I c.is_alpha()
|
||||
V p = c.code - ‘A’.code + 1
|
||||
v = p + 9
|
||||
E I c == ‘*’
|
||||
v = 36
|
||||
E I c == ‘@’
|
||||
v = 37
|
||||
E I c == ‘#’
|
||||
v = 38
|
||||
|
||||
I i % 2 != 0
|
||||
v *= 2
|
||||
|
||||
total += v I/ 10 + v % 10
|
||||
V check = (10 - (total % 10)) % 10
|
||||
R String(check) == cusip.last
|
||||
|
||||
V codes = [‘037833100’,
|
||||
‘17275R102’,
|
||||
‘38259P508’,
|
||||
‘594918104’,
|
||||
‘68389X106’,
|
||||
‘68389X105’]
|
||||
L(code) codes
|
||||
print(code‘: ’(I cusip_check(code) {‘valid’} E ‘invalid’))
|
||||
Loading…
Add table
Add a link
Reference in a new issue