RosettaCodeData/Task/SEDOLs/Python/sedols-1.py

26 lines
453 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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)
)
2024-04-19 16:56:29 -07:00
return str((-tmp) % 10)
2023-07-01 11:58:00 -04:00
for sedol in '''
710889
B0YBKJ
406566
B0YBLH
228276
B0YBKL
557910
B0YBKR
585284
B0YBKT
'''.split():
print sedol + checksum(sedol)