How to resolve the algorithm CUSIP step by step in the AutoHotkey programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm CUSIP step by step in the AutoHotkey programming language
Table of Contents
Problem Statement
A CUSIP is a nine-character alphanumeric code that identifies a North American financial security for the purposes of facilitating clearing and settlement of trades. The CUSIP was adopted as an American National Standard under Accredited Standards X9.6.
Ensure the last digit (i.e., the check digit) of the CUSIP code (the 1st column) is correct, against the following:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm CUSIP step by step in the AutoHotkey programming language
Source code in the autohotkey programming language
Cusip_Check_Digit(cusip){
sum := 0, i := 1, x := StrSplit(cusip)
while (i <= 8) {
c := x[i]
if c is digit
v := c
else if c is alpha
v := Asc(c) - 64 + 9
else if (c = "*")
v := 36
else if (c = "@")
v := 37
else if (c = "#")
v := 38
if (i/2 = Floor(i/2))
v *= 2
sum += Floor(v/10) + Mod(v, 10)
i++
}
return (Mod(10 - Mod(sum, 10), 10) = x[9])
}
data =
(
037833100
17275R102
38259P508
594918104
68389X106
68389X105
)
output := "Cusip`t`tValid`n"
loop, Parse, data, `n, `r
output .= A_LoopField "`t" Cusip_Check_Digit(A_LoopField) "`n"
MsgBox % output
You may also check:How to resolve the algorithm Create an object at a given address step by step in the Racket programming language
You may also check:How to resolve the algorithm 24 game step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Matrix multiplication step by step in the Futhark programming language
You may also check:How to resolve the algorithm Sieve of Pritchard step by step in the J programming language
You may also check:How to resolve the algorithm Mutex step by step in the Wren programming language