How to resolve the algorithm SEDOLs step by step in the Q programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm SEDOLs step by step in the Q programming language
Table of Contents
Problem Statement
For each number list of 6-digit SEDOLs, calculate and append the checksum digit.
That is, given this input: Produce this output: Check each input is correctly formed, especially with respect to valid characters allowed in a SEDOL string.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm SEDOLs step by step in the Q programming language
Source code in the q programming language
scd:{
v:{("i"$x) - ?[("0"<=x) & x<="9"; "i"$"0"; -10+"i"$"A"]} each x; / Turn characters of SEDOL into their values
w:sum v*1 3 1 7 3 9; / Weighted sum of values
d:(10 - w mod 10) mod 10; / Check digit value
x,"c"$(("i"$"0")+d) / Append to SEDOL
}
scd each ("710889";"B0YBKJ";"406566";"B0YBLH";"228276";"B0YBKL";"557910";"B0YBKR";"585284";"B0YBKT";"B00030")
You may also check:How to resolve the algorithm Append a record to the end of a text file step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Sequence of primes by trial division step by step in the Elixir programming language
You may also check:How to resolve the algorithm Strong and weak primes step by step in the Python programming language
You may also check:How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the Haskell programming language
You may also check:How to resolve the algorithm Hello world/Newline omission step by step in the ML/I programming language