Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

34
Task/IBAN/J/iban.j Normal file
View file

@ -0,0 +1,34 @@
NB. delete any blank characters
delblk =. #~ ' '&~:
NB. rearrange
rot =. '00' ,~ 2&}. @: (2&|.)
NB. characters -> "digits"
dig =. a. {~ (a.i.'0')+i.10
dig =. dig,a. {~ (a.i.'A')+i.26
todig =. dig&i.
coded =. [: ". 'x' ,~ delblk @: ": @: todig
NB. calculate check sum
cs =: 98 - 97 | coded @: rot @: delblk f.
NB. check sum as text
cstxt =. _2{. '0', [: ": cs
NB. replace first two characters
chgps =. [,2}.]
NB. shift country code
rotlc =. 2&|.
NB. insert check digits (position 3 and 4)
insertps =. chgps &.rotlc
NB. IBAN with newly calculated check digits
ibancd =: (cstxt insertps ]) f.
NB. check / generate check digits
ibancheck =: ] (]`('ok'"_) @. -:) ibancd
NB. groups of four characters
insertblk =. #~ # $ 1 1 1 1j1"_
quads =: insertblk @: delblk f.
NB. IBAN
iban =: quads @: ibancheck