Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
40
Task/SEDOLs/Ada/sedols.adb
Normal file
40
Task/SEDOLs/Ada/sedols.adb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
|
||||
procedure Test_SEDOL is
|
||||
|
||||
subtype SEDOL_String is String (1..6);
|
||||
type SEDOL_Sum is range 0..9;
|
||||
|
||||
function Check (SEDOL : SEDOL_String) return SEDOL_Sum is
|
||||
Weight : constant array (SEDOL_String'Range) of Integer := (1,3,1,7,3,9);
|
||||
Sum : Integer := 0;
|
||||
Item : Integer;
|
||||
begin
|
||||
for Index in SEDOL'Range loop
|
||||
Item := Character'Pos (SEDOL (Index));
|
||||
case Item is
|
||||
when Character'Pos ('0')..Character'Pos ('9') =>
|
||||
Item := Item - Character'Pos ('0');
|
||||
when Character'Pos ('B')..Character'Pos ('D') |
|
||||
Character'Pos ('F')..Character'Pos ('H') |
|
||||
Character'Pos ('J')..Character'Pos ('N') |
|
||||
Character'Pos ('P')..Character'Pos ('T') |
|
||||
Character'Pos ('V')..Character'Pos ('Z') =>
|
||||
Item := Item - Character'Pos ('A') + 10;
|
||||
when others =>
|
||||
raise Constraint_Error;
|
||||
end case;
|
||||
Sum := Sum + Item * Weight (Index);
|
||||
end loop;
|
||||
return SEDOL_Sum ((-Sum) mod 10);
|
||||
end Check;
|
||||
|
||||
Test : constant array (1..10) of SEDOL_String :=
|
||||
( "710889", "B0YBKJ", "406566", "B0YBLH", "228276",
|
||||
"B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT"
|
||||
);
|
||||
begin
|
||||
for Index in Test'Range loop
|
||||
Put_Line (Test (Index) & Character'Val (Character'Pos ('0') + Check (Test (Index))));
|
||||
end loop;
|
||||
end Test_SEDOL;
|
||||
79
Task/SEDOLs/COBOL/sedols.cob
Normal file
79
Task/SEDOLs/COBOL/sedols.cob
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
>>SOURCE FREE
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. sedol.
|
||||
|
||||
ENVIRONMENT DIVISION.
|
||||
INPUT-OUTPUT SECTION.
|
||||
FILE-CONTROL.
|
||||
SELECT sedol-file ASSIGN "sedol.txt"
|
||||
ORGANIZATION LINE SEQUENTIAL
|
||||
FILE STATUS sedol-file-status.
|
||||
|
||||
DATA DIVISION.
|
||||
FILE SECTION.
|
||||
FD sedol-file.
|
||||
01 sedol PIC X(6).
|
||||
|
||||
WORKING-STORAGE SECTION.
|
||||
01 sedol-file-status PIC XX.
|
||||
88 sedol-file-ok VALUE "00".
|
||||
|
||||
01 digit-num PIC 9 COMP.
|
||||
|
||||
01 digit-weights-area VALUE "1317391".
|
||||
03 digit-weights PIC 9 OCCURS 7 TIMES.
|
||||
|
||||
01 weighted-sum-parts-area.
|
||||
03 weighted-sum-parts PIC 9(3) COMP OCCURS 6 TIMES.
|
||||
|
||||
01 weighted-sum PIC 9(3) COMP.
|
||||
|
||||
01 check-digit PIC 9.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
OPEN INPUT sedol-file
|
||||
PERFORM UNTIL NOT sedol-file-ok
|
||||
READ sedol-file
|
||||
AT END
|
||||
EXIT PERFORM
|
||||
END-READ
|
||||
|
||||
MOVE FUNCTION UPPER-CASE(sedol) TO sedol
|
||||
|
||||
PERFORM VARYING digit-num FROM 1 BY 1 UNTIL digit-num > 6
|
||||
EVALUATE TRUE
|
||||
WHEN sedol (digit-num:1) IS ALPHABETIC-UPPER
|
||||
IF sedol (digit-num:1) = "A" OR "E" OR "I" OR "O" OR "U"
|
||||
DISPLAY "Invalid SEDOL: " sedol
|
||||
EXIT PERFORM CYCLE
|
||||
END-IF
|
||||
|
||||
COMPUTE weighted-sum-parts (digit-num) =
|
||||
(FUNCTION ORD(sedol (digit-num:1)) - FUNCTION ORD("A")
|
||||
+ 10) * digit-weights (digit-num)
|
||||
|
||||
WHEN sedol (digit-num:1) IS NUMERIC
|
||||
MULTIPLY FUNCTION NUMVAL(sedol (digit-num:1))
|
||||
BY digit-weights (digit-num)
|
||||
GIVING weighted-sum-parts (digit-num)
|
||||
|
||||
WHEN OTHER
|
||||
DISPLAY "Invalid SEDOL: " sedol
|
||||
EXIT PERFORM CYCLE
|
||||
END-EVALUATE
|
||||
END-PERFORM
|
||||
|
||||
INITIALIZE weighted-sum
|
||||
PERFORM VARYING digit-num FROM 1 BY 1 UNTIL digit-num > 6
|
||||
ADD weighted-sum-parts (digit-num) TO weighted-sum
|
||||
END-PERFORM
|
||||
|
||||
COMPUTE check-digit =
|
||||
FUNCTION MOD(10 - FUNCTION MOD(weighted-sum, 10), 10)
|
||||
|
||||
DISPLAY sedol check-digit
|
||||
END-PERFORM
|
||||
|
||||
CLOSE sedol-file
|
||||
.
|
||||
END PROGRAM sedol.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import std.stdio, std.algorithm, std.string, std.numeric, std.ascii;
|
||||
|
||||
char sedolChecksum(in char[] sedol) pure nothrow @safe /*@nogc*/
|
||||
char sedolChecksum(in char[] sedol) pure @safe /*@nogc*/
|
||||
in {
|
||||
assert(sedol.length == 6, "SEDOL must be 6 chars long.");
|
||||
enum uint mask = 0b11_1110_1111_1011_1110_1110_1110;
|
||||
|
|
@ -16,7 +16,7 @@ in {
|
|||
}
|
||||
immutable int d = sedol.map!c2v.dotProduct([1, 3, 1, 7, 3, 9]);
|
||||
assert((d + result - '0') % 10 == 0);
|
||||
} body {
|
||||
} do {
|
||||
static immutable int[] weights = [1, 3, 1, 7, 3, 9];
|
||||
|
||||
int sum = 0;
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
using Base.Test
|
||||
using Test
|
||||
|
||||
function appendchecksum(chars::AbstractString)
|
||||
if !all(isalnum, chars) throw(ArgumentError("invalid SEDOL number '$chars'")) end
|
||||
weights = [1, 3, 1, 7, 3, 9, 1]
|
||||
isalnum(c::Char) = isletter(c) || isnumeric(c)
|
||||
|
||||
s = 0
|
||||
for (w, c) in zip(weights, chars)
|
||||
s += w * parse(Int, c, 36)
|
||||
end
|
||||
return string(chars, (10 - s % 10) % 10)
|
||||
function appendchecksum(s::AbstractString)
|
||||
!all(isalnum, s) && throw(ArgumentError("invalid SEDOL number '$s'"))
|
||||
|
||||
weights = [1, 3, 1, 7, 3, 9, 1]
|
||||
checksum = sum(weights[i] * parse(Int, s[i], base = 36) for i in eachindex(s))
|
||||
return s * string((10 - checksum % 10) % 10)
|
||||
end
|
||||
|
||||
tests = ["710889", "B0YBKJ", "406566", "B0YBLH", "228276", "B0YBKL", "557910", "B0YBKR", "585284", "B0YBKT", "B00030"]
|
||||
|
|
|
|||
|
|
@ -1,26 +1,41 @@
|
|||
function char2value($c) {
|
||||
<?php
|
||||
|
||||
function char2value($c)
|
||||
{
|
||||
assert(stripos('AEIOU', $c) === FALSE);
|
||||
return intval($c, 36);
|
||||
}
|
||||
|
||||
$sedolweight = array(1,3,1,7,3,9);
|
||||
$sedolweight = array(1, 3, 1, 7, 3, 9);
|
||||
|
||||
function checksum($sedol) {
|
||||
global $sedolweight;
|
||||
$tmp = array_sum(array_map(create_function('$ch, $weight', 'return char2value($ch) * $weight;'),
|
||||
str_split($sedol), $sedolweight)
|
||||
);
|
||||
return strval((10 - ($tmp % 10)) % 10);
|
||||
function checksum($sedol)
|
||||
{
|
||||
global $sedolweight;
|
||||
$tmp = array_sum(
|
||||
array_map(
|
||||
function ($ch, $weight) {
|
||||
return char2value($ch) * $weight;
|
||||
},
|
||||
str_split($sedol),
|
||||
$sedolweight
|
||||
)
|
||||
);
|
||||
return strval((10 - ($tmp % 10)) % 10);
|
||||
}
|
||||
|
||||
foreach (array('710889',
|
||||
'B0YBKJ',
|
||||
'406566',
|
||||
'B0YBLH',
|
||||
'228276',
|
||||
'B0YBKL',
|
||||
'557910',
|
||||
'B0YBKR',
|
||||
'585284',
|
||||
'B0YBKT') as $sedol)
|
||||
echo $sedol, checksum($sedol), "\n";
|
||||
foreach (
|
||||
array(
|
||||
'710889',
|
||||
'B0YBKJ',
|
||||
'406566',
|
||||
'B0YBLH',
|
||||
'228276',
|
||||
'B0YBKL',
|
||||
'557910',
|
||||
'B0YBKR',
|
||||
'585284',
|
||||
'B0YBKT',
|
||||
'B00030'
|
||||
) as $sedol
|
||||
)
|
||||
echo $sedol, checksum($sedol), "\n";
|
||||
|
|
|
|||
|
|
@ -1,34 +1,29 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #008080;">type</span> <span style="color: #000000;">string6</span><span style="color: #0000FF;">(</span><span style="color: #004080;">object</span> <span style="color: #000000;">s</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #004080;">string</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">and</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">)=</span><span style="color: #000000;">6</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">type</span>
|
||||
with javascript_semantics
|
||||
constant cmap = reinstate(reinstate(reinstate(repeat(-1,255),
|
||||
tagset('9','0'),tagset(9,0)),
|
||||
tagset('Z','B'),tagset(35,11)),"EIOU",-1)
|
||||
|
||||
<span style="color: #008080;">type</span> <span style="color: #000000;">sedolch</span><span style="color: #0000FF;">(</span><span style="color: #004080;">integer</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">>=</span><span style="color: #008000;">'0'</span> <span style="color: #008080;">and</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;"><=</span><span style="color: #008000;">'Z'</span> <span style="color: #008080;">and</span> <span style="color: #0000FF;">(</span><span style="color: #000000;">ch</span><span style="color: #0000FF;"><=</span><span style="color: #008000;">'9'</span> <span style="color: #008080;">or</span> <span style="color: #000000;">ch</span><span style="color: #0000FF;">>=</span><span style="color: #008000;">'A'</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">and</span> <span style="color: #008080;">not</span> <span style="color: #7060A8;">find</span><span style="color: #0000FF;">(</span><span style="color: #000000;">ch</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"AEIOU"</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">type</span>
|
||||
function sedol(string t)
|
||||
string s = filter(t,"out","-")
|
||||
integer l = length(s)
|
||||
string res = "invalid length"
|
||||
if l=6 or l=7 then
|
||||
sequence e = extract(cmap,s[1..6])
|
||||
if find(-1,e) then
|
||||
res = "invalid char"
|
||||
elsif e[1]<=9 and max(e)>9 then
|
||||
res = "no letters when starts with number"
|
||||
else
|
||||
integer n = sum(sq_mul(e,{1,3,1,7,3,9})),
|
||||
ch = mod(10-mod(n,10),10)+'0'
|
||||
res = iff(l=7 ? "invalid checksum"[iff(ch=s[7]?3:1)..$] : t&ch)
|
||||
end if
|
||||
end if
|
||||
return res
|
||||
end function
|
||||
|
||||
<span style="color: #008080;">function</span> <span style="color: #000000;">sedol</span><span style="color: #0000FF;">(</span><span style="color: #000000;">string6</span> <span style="color: #000000;">t</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #000000;">sedolch</span> <span style="color: #000000;">c</span>
|
||||
<span style="color: #004080;">integer</span> <span style="color: #000000;">s</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">6</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #000000;">c</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">t</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #000000;">s</span> <span style="color: #0000FF;">+=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">>=</span><span style="color: #008000;">'A'</span><span style="color: #0000FF;">?</span><span style="color: #000000;">c</span><span style="color: #0000FF;">-</span><span style="color: #008000;">'A'</span><span style="color: #0000FF;">+</span><span style="color: #000000;">10</span><span style="color: #0000FF;">:</span><span style="color: #000000;">c</span><span style="color: #0000FF;">-</span><span style="color: #008000;">'0'</span><span style="color: #0000FF;">)*{</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">9</span><span style="color: #0000FF;">}[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
|
||||
<span style="color: #008080;">return</span> <span style="color: #000000;">t</span> <span style="color: #0000FF;">&</span> <span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">10</span><span style="color: #0000FF;">-</span><span style="color: #7060A8;">mod</span><span style="color: #0000FF;">(</span><span style="color: #000000;">s</span><span style="color: #0000FF;">,</span><span style="color: #000000;">10</span><span style="color: #0000FF;">),</span><span style="color: #000000;">10</span><span style="color: #0000FF;">)+</span><span style="color: #008000;">'0'</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
|
||||
|
||||
<span style="color: #008080;">constant</span> <span style="color: #000000;">tests</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #008000;">"710889"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B0YBKJ"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"406566"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B0YBLH"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"228276"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B0YBKL"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"557910"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B0YBKR"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"585284"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B0YBKT"</span><span style="color: #0000FF;">,</span>
|
||||
<span style="color: #008000;">"B00030"</span><span style="color: #0000FF;">}</span>
|
||||
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tests</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #000000;">sedol</span><span style="color: #0000FF;">(</span><span style="color: #000000;">tests</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">])</span>
|
||||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
|
||||
<!--
|
||||
for t in {"710889","B0YBKJ","406566","B0YBLH","228276","B0YBKL","557910","B0YBKR",
|
||||
"585284","B0YBKT","B00030","B000300","B000301","","12","12345","BOYBKR",
|
||||
"B1F3M59","B-1H5-4P6","B-123-45","ZZZZZZ","1ZZZZZ","123456","1234567"} do
|
||||
printf(1,"%s -> %s\n",{t,sedol(t)})
|
||||
end for
|
||||
|
|
|
|||
35
Task/SEDOLs/Pluto/sedols.pluto
Normal file
35
Task/SEDOLs/Pluto/sedols.pluto
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
local function sedol(s)
|
||||
if not(type(s) == "string" and #s == 6) then return false end
|
||||
local weights = {1, 3, 1, 7, 3, 9}
|
||||
local sum = 0
|
||||
for i = 1, 6 do
|
||||
local c = s[i]
|
||||
if not c:isupper() and not(c in "0123456789") then
|
||||
return nil
|
||||
end
|
||||
if c in "AEIOU" then return nil end
|
||||
sum += tonumber(c, 36) * weights[i]
|
||||
end
|
||||
local cd = (10 - sum % 10) % 10
|
||||
return s .. $"{cd}"
|
||||
end
|
||||
|
||||
local tests = {
|
||||
"710889",
|
||||
"B0YBKJ",
|
||||
"406566",
|
||||
"B0YBLH",
|
||||
"228276",
|
||||
"B0YBKL",
|
||||
"557910",
|
||||
"B0YBKR",
|
||||
"585284",
|
||||
"B0YBKT",
|
||||
"B00030",
|
||||
"I23456"
|
||||
}
|
||||
|
||||
for tests as test do
|
||||
local ans = sedol(test) ?? "not valid"
|
||||
print($"{test} -> {ans}")
|
||||
end
|
||||
48
Task/SEDOLs/PowerShell/sedols.ps1
Normal file
48
Task/SEDOLs/PowerShell/sedols.ps1
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
function Add-SEDOLCheckDigit
|
||||
{
|
||||
Param ( # Validate input as six-digit SEDOL number
|
||||
[ValidatePattern( "^[0123456789bcdfghjklmnpqrstvwxyz]{6}$" )]
|
||||
[parameter ( Mandatory = $True ) ]
|
||||
[string]
|
||||
$SixDigitSEDOL )
|
||||
|
||||
# Convert to array of single character strings, using type char as an intermediary
|
||||
$SEDOL = [string[]][char[]]$SixDigitSEDOL
|
||||
|
||||
# Define place weights
|
||||
$Weight = @( 1, 3, 1, 7, 3, 9 )
|
||||
|
||||
# Define character values (implicit in 0-based location within string)
|
||||
$Characters = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
$CheckSum = 0
|
||||
|
||||
# For each digit, multiply the character value by the weight and add to check sum
|
||||
0..5 | ForEach { $CheckSum += $Characters.IndexOf( $SEDOL[$_].ToLower() ) * $Weight[$_] }
|
||||
|
||||
# Derive the check digit from the partial check sum
|
||||
$CheckDigit = ( 10 - $CheckSum % 10 ) % 10
|
||||
|
||||
# Return concatenated result
|
||||
return ( $SixDigitSEDOL + $CheckDigit )
|
||||
}
|
||||
|
||||
# Test
|
||||
$List = @(
|
||||
"710889"
|
||||
"B0YBKJ"
|
||||
"406566"
|
||||
"B0YBLH"
|
||||
"228276"
|
||||
"B0YBKL"
|
||||
"557910"
|
||||
"B0YBKR"
|
||||
"585284"
|
||||
"B0YBKT"
|
||||
"B00030"
|
||||
)
|
||||
|
||||
ForEach ( $PartialSEDOL in $List )
|
||||
{
|
||||
Add-SEDOLCheckDigit -SixDigitSEDOL $PartialSEDOL
|
||||
}
|
||||
|
|
@ -22,4 +22,4 @@ for sedol in '''
|
|||
585284
|
||||
B0YBKT
|
||||
'''.split():
|
||||
print sedol + checksum(sedol)
|
||||
print (sedol + checksum(sedol))
|
||||
|
|
|
|||
25
Task/SEDOLs/V-(Vlang)/sedols.v
Normal file
25
Task/SEDOLs/V-(Vlang)/sedols.v
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import strconv
|
||||
|
||||
const weights = [1, 3, 1, 7, 3, 9, 1]
|
||||
|
||||
fn main() {
|
||||
sedol6s := [
|
||||
"710889", "B0YBKJ", "406566", "B0YBLH", "228276", "B0YBKL",
|
||||
"557910", "B0YBKR", "585284", "B0YBKT", "B00030", "1234567890",
|
||||
"B000301", "A00000", "12🦊", "β0003", "A00030"]
|
||||
for sedol6 in sedol6s { println("${sedol6} -> ${sedol7(sedol6) or {continue}}") }
|
||||
}
|
||||
|
||||
fn sedol7(sedol6 string) !string {
|
||||
mut sum, mut check := 0, 0
|
||||
if sedol6.len != 6 { return "'Incorrect length!'" }
|
||||
for i, c in sedol6 {
|
||||
if !c.is_alnum() || c.ascii_str().is_lower()
|
||||
|| c.ascii_str() in ["A", "E", "I", "O", "U"] { return "'Illegal character!'" }
|
||||
digit := strconv.common_parse_int(c.ascii_str(), 36, 0, true, true) or
|
||||
{ return "'Invalid conversion!'" }
|
||||
sum += int(digit) * weights[i]
|
||||
}
|
||||
check = (10 - (sum % 10)) % 10
|
||||
return "${sedol6}" + "${check.str()}"
|
||||
}
|
||||
44
Task/SEDOLs/VBScript/sedols.vbs
Normal file
44
Task/SEDOLs/VBScript/sedols.vbs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
arr = Array("710889",_
|
||||
"B0YBKJ",_
|
||||
"406566",_
|
||||
"B0YBLH",_
|
||||
"228276",_
|
||||
"B0YBKL",_
|
||||
"557910",_
|
||||
"B0YBKR",_
|
||||
"585284",_
|
||||
"B0YBKT",_
|
||||
"12345",_
|
||||
"A12345",_
|
||||
"B00030")
|
||||
|
||||
For j = 0 To UBound(arr)
|
||||
WScript.StdOut.Write arr(j) & getSEDOLCheckDigit(arr(j))
|
||||
WScript.StdOut.WriteLine
|
||||
Next
|
||||
|
||||
Function getSEDOLCheckDigit(str)
|
||||
If Len(str) <> 6 Then
|
||||
getSEDOLCheckDigit = " is invalid. Only 6 character strings are allowed."
|
||||
Exit Function
|
||||
End If
|
||||
Set mult = CreateObject("Scripting.Dictionary")
|
||||
With mult
|
||||
.Add "1","1" : .Add "2", "3" : .Add "3", "1"
|
||||
.Add "4","7" : .Add "5", "3" : .Add "6", "9"
|
||||
End With
|
||||
total = 0
|
||||
For i = 1 To 6
|
||||
s = Mid(str,i,1)
|
||||
If s = "A" Or s = "E" Or s = "I" Or s = "O" Or s = "U" Then
|
||||
getSEDOLCheckDigit = " is invalid. Vowels are not allowed."
|
||||
Exit Function
|
||||
End If
|
||||
If Asc(s) >= 48 And Asc(s) <=57 Then
|
||||
total = total + CInt(s) * CInt(mult.Item(CStr(i)))
|
||||
Else
|
||||
total = total + (Asc(s) - 55) * CInt(mult.Item(CStr(i)))
|
||||
End If
|
||||
Next
|
||||
getSEDOLCheckDigit = (10 - total Mod 10) Mod 10
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue