Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
23
Task/CUSIP/Langur/cusip-1.langur
Normal file
23
Task/CUSIP/Langur/cusip-1.langur
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
val .isCusip = f(.s) {
|
||||
if not isString(.s) or len(.s) != 9 {
|
||||
return false
|
||||
}
|
||||
|
||||
val .basechars = cp2s('0'..'9') ~ cp2s('A'..'Z') ~ "*@#"
|
||||
|
||||
val .sum = for[=0] .i of 8 {
|
||||
var .v = index(s2s(.s, .i), .basechars)
|
||||
if not .v: return false
|
||||
.v = .v[1]-1
|
||||
if .i div 2: .v x= 2
|
||||
_for += .v \ 10 + .v rem 10
|
||||
}
|
||||
|
||||
.s[9]-'0' == (10-(.sum rem 10)) rem 10
|
||||
}
|
||||
|
||||
val .candidates = w/037833100 17275R102 38259P508 594918104 68389X106 68389X105/
|
||||
|
||||
for .c in .candidates {
|
||||
writeln .c, ": ", if(.isCusip(.c): "good" ; "bad")
|
||||
}
|
||||
37
Task/CUSIP/Langur/cusip-2.langur
Normal file
37
Task/CUSIP/Langur/cusip-2.langur
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
val .isCusip = f(.s) {
|
||||
if not isString(.s) or len(.s) != 9 {
|
||||
return false
|
||||
}
|
||||
|
||||
val .sum = for[=0] .i of 8 {
|
||||
val .c = .s[.i]
|
||||
var .v = 0
|
||||
|
||||
given .c {
|
||||
# for given, default op between conditions is "and"
|
||||
# for switch, default op between conditions is "or"
|
||||
case >= '0', <= '9':
|
||||
.v = .c-'0'
|
||||
|
||||
case >= 'A', <= 'Z':
|
||||
.v = .c-55 # .c-'A'+10
|
||||
|
||||
case '*': .v = 36
|
||||
case '@': .v = 37
|
||||
case '#': .v = 38
|
||||
|
||||
default: return false
|
||||
}
|
||||
|
||||
if .i div 2: .v x= 2
|
||||
_for += .v \ 10 + .v rem 10
|
||||
}
|
||||
|
||||
.s[9]-'0' == (10-(.sum rem 10)) rem 10
|
||||
}
|
||||
|
||||
val .candidates = w/037833100 17275R102 38259P508 594918104 68389X106 68389X105/
|
||||
|
||||
for .c in .candidates {
|
||||
writeln .c, ": ", if(.isCusip(.c): "good" ; "bad")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue