Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
38
Task/CUSIP/Dyalect/cusip.dyalect
Normal file
38
Task/CUSIP/Dyalect/cusip.dyalect
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
func isCusip(s) {
|
||||
if s.Length() != 9 { return false }
|
||||
var sum = 0
|
||||
for i in 0..7 {
|
||||
var c = s[i]
|
||||
var v =
|
||||
match c {
|
||||
'0'..'9' => c.Order() - 48,
|
||||
'A'..'Z' => c.Order() - 55,
|
||||
'*' => 36,
|
||||
'@' => 37,
|
||||
'#' => 38,
|
||||
_ => false
|
||||
}
|
||||
if i % 2 == 1 { v *= 2 }
|
||||
sum += v / 10 + v % 10
|
||||
}
|
||||
s[8].Order() - 48 == (10 - (sum % 10)) % 10
|
||||
}
|
||||
|
||||
var candidates = [
|
||||
"037833100",
|
||||
"17275R102",
|
||||
"38259P508",
|
||||
"594918104",
|
||||
"68389X106",
|
||||
"68389X105"
|
||||
]
|
||||
|
||||
for candidate in candidates {
|
||||
var b =
|
||||
if isCusip(candidate) {
|
||||
"correct"
|
||||
} else {
|
||||
"incorrect"
|
||||
}
|
||||
print("\(candidate) -> \(b)")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue