Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
58
Task/CUSIP/Objeck/cusip.objeck
Normal file
58
Task/CUSIP/Objeck/cusip.objeck
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
class Cusip {
|
||||
function : native : IsCusip(s : String) ~ Bool {
|
||||
if(s->Size() <> 9) {
|
||||
return false;
|
||||
};
|
||||
|
||||
sum := 0;
|
||||
for(i := 0; i < 7; i+=1;) {
|
||||
c := s->Get(i);
|
||||
|
||||
v : Int;
|
||||
if (c >= '0' & c <= '9') {
|
||||
v := c - 48;
|
||||
} else if (c >= 'A' & c <= 'Z') {
|
||||
v := c - 55; # lower case letters apparently invalid
|
||||
} else if (c = '*') {
|
||||
v := 36;
|
||||
} else if (c = '@') {
|
||||
v := 37;
|
||||
} else if (c = '#') {
|
||||
v := 38;
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
|
||||
# check if odd as using 0-based indexing
|
||||
if(i % 2 = 1) {
|
||||
v *= 2;
|
||||
};
|
||||
|
||||
sum += v / 10 + v % 10;
|
||||
};
|
||||
|
||||
return s->Get(8) - 48 = (10 - (sum % 10)) % 10;
|
||||
}
|
||||
|
||||
function : Main(args : String[]) ~ Nil {
|
||||
candidates := [
|
||||
"037833100",
|
||||
"17275R102",
|
||||
"38259P508",
|
||||
"594918104",
|
||||
"68389X106",
|
||||
"68389X105"
|
||||
];
|
||||
|
||||
each(i : candidates) {
|
||||
candidate := candidates[i];
|
||||
"{$candidate} => "->Print();
|
||||
if(IsCusip(candidate)) {
|
||||
"correct"->PrintLine();
|
||||
}
|
||||
else {
|
||||
"incorrect"->PrintLine();
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue