Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
57
Task/IBAN/Seed7/iban.seed7
Normal file
57
Task/IBAN/Seed7/iban.seed7
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
$ include "seed7_05.s7i";
|
||||
include "bigint.s7i";
|
||||
|
||||
const type: countryHash is hash [string] integer;
|
||||
|
||||
const func countryHash: initCountryCode is func
|
||||
result
|
||||
var countryHash: cc is countryHash.value;
|
||||
begin
|
||||
cc @:= ["AL"] 28; cc @:= ["AD"] 24; cc @:= ["AT"] 20; cc @:= ["AZ"] 28; cc @:= ["BE"] 16; cc @:= ["BH"] 22;
|
||||
cc @:= ["BA"] 20; cc @:= ["BR"] 29; cc @:= ["BG"] 22; cc @:= ["CR"] 21; cc @:= ["HR"] 21; cc @:= ["CY"] 28;
|
||||
cc @:= ["CZ"] 24; cc @:= ["DK"] 18; cc @:= ["DO"] 28; cc @:= ["EE"] 20; cc @:= ["FO"] 18; cc @:= ["FI"] 18;
|
||||
cc @:= ["FR"] 27; cc @:= ["GE"] 22; cc @:= ["DE"] 22; cc @:= ["GI"] 23; cc @:= ["GR"] 27; cc @:= ["GL"] 18;
|
||||
cc @:= ["GT"] 28; cc @:= ["HU"] 28; cc @:= ["IS"] 26; cc @:= ["IE"] 22; cc @:= ["IL"] 23; cc @:= ["IT"] 27;
|
||||
cc @:= ["KZ"] 20; cc @:= ["KW"] 30; cc @:= ["LV"] 21; cc @:= ["LB"] 28; cc @:= ["LI"] 21; cc @:= ["LT"] 20;
|
||||
cc @:= ["LU"] 20; cc @:= ["MK"] 19; cc @:= ["MT"] 31; cc @:= ["MR"] 27; cc @:= ["MU"] 30; cc @:= ["MC"] 27;
|
||||
cc @:= ["MD"] 24; cc @:= ["ME"] 22; cc @:= ["NL"] 18; cc @:= ["NO"] 15; cc @:= ["PK"] 24; cc @:= ["PS"] 29;
|
||||
cc @:= ["PL"] 28; cc @:= ["PT"] 25; cc @:= ["RO"] 24; cc @:= ["SM"] 27; cc @:= ["SA"] 24; cc @:= ["RS"] 22;
|
||||
cc @:= ["SK"] 24; cc @:= ["SI"] 19; cc @:= ["ES"] 24; cc @:= ["SE"] 24; cc @:= ["CH"] 21; cc @:= ["TN"] 24;
|
||||
cc @:= ["TR"] 26; cc @:= ["AE"] 23; cc @:= ["GB"] 22; cc @:= ["VG"] 24;
|
||||
end func;
|
||||
|
||||
const countryHash: countryCode is initCountryCode;
|
||||
|
||||
const func boolean: isLegal (in var string: iban) is func
|
||||
result
|
||||
var boolean: legal is FALSE;
|
||||
local
|
||||
var char: ch is ' ';
|
||||
var string: converted is "";
|
||||
begin
|
||||
iban := upper(replace(iban, " ", ""));
|
||||
legal := iban[.. 2] in countryCode and countryCode[iban[.. 2]] = length(iban);
|
||||
iban := iban[5 ..] & iban[.. 4];
|
||||
for ch range iban do
|
||||
case ch of
|
||||
when {'0' .. '9'}: converted &:= ch;
|
||||
when {'A' .. 'Z'}: converted &:= str(ord(ch) - ord('A') + 10);
|
||||
otherwise: legal := FALSE;
|
||||
end case;
|
||||
end for;
|
||||
legal := legal and (bigInteger parse converted) rem 97_ = 1_;
|
||||
end func;
|
||||
|
||||
const proc: check (in string: iban) is func
|
||||
begin
|
||||
writeln("Valid " <& iban <& ": " <& isLegal(iban));
|
||||
end func;
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
check("GB82 WEST 1234 5698 7654 32");
|
||||
check("GB82WEST12345698765432");
|
||||
check("gb82 west 1234 5698 7654 32");
|
||||
check("GB82 TEST 1234 5698 7654 32");
|
||||
check("GB82 WEST 1243 5698 7654 32");
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue