tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
25
Task/SEDOLs/Python/sedols.py
Normal file
25
Task/SEDOLs/Python/sedols.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
def char2value(c):
|
||||
assert c not in 'AEIOU', "No vowels"
|
||||
return int(c, 36)
|
||||
|
||||
sedolweight = [1,3,1,7,3,9]
|
||||
|
||||
def checksum(sedol):
|
||||
tmp = sum(map(lambda ch, weight: char2value(ch) * weight,
|
||||
sedol, sedolweight)
|
||||
)
|
||||
return str((10 - (tmp % 10)) % 10)
|
||||
|
||||
for sedol in '''
|
||||
710889
|
||||
B0YBKJ
|
||||
406566
|
||||
B0YBLH
|
||||
228276
|
||||
B0YBKL
|
||||
557910
|
||||
B0YBKR
|
||||
585284
|
||||
B0YBKT
|
||||
'''.split():
|
||||
print sedol + checksum(sedol)
|
||||
Loading…
Add table
Add a link
Reference in a new issue