Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

30
Task/IBAN/MATLAB/iban-1.m Normal file
View file

@ -0,0 +1,30 @@
function valid = validateIBAN(iban)
% Determine if International Bank Account Number is valid IAW ISO 13616
% iban - string containing account number
if length(iban) < 5
valid = false;
else
iban(iban == ' ') = ''; % Remove spaces
iban = lower([iban(5:end) iban(1:4)])+0; % Rearrange and convert
iban(iban > 96 & iban < 123) = iban(iban > 96 & iban < 123)-87; % Letters
iban(iban > 47 & iban < 58) = iban(iban > 47 & iban < 58)-48; % Numbers
valid = piecewiseMod97(iban) == 1;
end
end
function result = piecewiseMod97(x)
% Conduct a piecewise version of mod(x, 97) to support large integers
% x is a vector of integers
x = sprintf('%d', x); % Get to single-digits per index
nDig = length(x);
i1 = 1;
i2 = min(9, nDig);
prefix = '';
while i1 <= nDig
y = str2double([prefix x(i1:i2)]);
result = mod(y, 97);
prefix = sprintf('%d', result);
i1 = i2+1;
i2 = min(i1+8, nDig);
end
end

11
Task/IBAN/MATLAB/iban-2.m Normal file
View file

@ -0,0 +1,11 @@
tests = {'GB82 WEST 1234 5698 7654 32' ;
'GB82 TEST 1234 5698 7654 32' ;
'CH93 0076 2011 6238 5295 7' ;
'SA03 8000 0000 6080 1016 7519' ;
'SA03 1234 5678 9101 1121 3141' ;
'GB29 NWBK 6016 1331 9268 19' ;
'GB29' ;
'GR16 0110 1250 0000 0001 2300 695'};
for k = 1:length(tests)
fprintf('%s -> %svalid\n', tests{k}, char(~validateIBAN(tests{k}).*'in'))
end