Data update
This commit is contained in:
parent
4924dd0264
commit
cb74b7914d
|
|
@ -1,3 +1,4 @@
|
|||
/*.ys
|
||||
/Cache/
|
||||
/Meta/
|
||||
/rosettacode.log
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
../../Task/Luhn-test-of-credit-card-numbers/YAMLScript
|
||||
|
|
@ -0,0 +1 @@
|
|||
../../Task/Validate-International-Securities-Identification-Number/YAMLScript
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(input):
|
||||
say: read-string(input)
|
||||
.map(best-shuffle):vec
|
||||
defn main(*inputs):
|
||||
each input inputs: !:say
|
||||
apply format '%s, %s, (%d)':
|
||||
best-shuffle(input)
|
||||
|
||||
defn best-shuffle(s):
|
||||
ref =: s:group-indices:cycles
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(x):
|
||||
defn main(*xs):
|
||||
each x xs:
|
||||
if x:even?:
|
||||
say: "$x is even"
|
||||
say: "$x is odd"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(n=10):
|
||||
defn main(*ns):
|
||||
each n ns:
|
||||
say: "$n! -> $factorial(n)"
|
||||
|
||||
defn factorial(x):
|
||||
2 .. x: .mul(*)
|
||||
if x <= 2:
|
||||
(x ||| 1)
|
||||
(2 .. x).mul(*)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
proc multiply { a b args } {
|
||||
|
||||
set product 1
|
||||
|
||||
foreach m [list $a $b {*}$args] {
|
||||
|
||||
set product [expr {$product * $m}]
|
||||
}
|
||||
|
||||
return $product
|
||||
}
|
||||
|
||||
puts stdout [multiply 3 4 7 9 -2 -5 ]
|
||||
|
|
@ -17,7 +17,7 @@ gcd(a,b)
|
|||
|
||||
printGCD(a,b)
|
||||
{
|
||||
console.printLineFormatted("GCD of {0} and {1} is {2}", a, b, gcd(a,b))
|
||||
Console.printLineFormatted("GCD of {0} and {1} is {2}", a, b, gcd(a,b))
|
||||
}
|
||||
|
||||
public program()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(*nums):
|
||||
each cc nums:
|
||||
say: "$cc - $if(cc:luhn? 'valid' 'invalid')"
|
||||
|
||||
defn luhn?(cc):
|
||||
map(mul cc:digits:reverse [1 2]:cycle)
|
||||
.map(\(I(_ / 10) + (_ % 10))):sum
|
||||
.mod(10):zero?
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
!YS-v0
|
||||
|
||||
defn main(*nums):
|
||||
each isin nums:
|
||||
say: "$isin - $if(isin:isin? 'valid' 'invalid')"
|
||||
|
||||
defn isin?(isin):
|
||||
isin.re-matches(/[A-Z]{2}[A-Z0-9]{9}[0-9]/) &&
|
||||
isin.map(b36-10).apply(str):luhn?
|
||||
|
||||
defn b36-10(c):
|
||||
c =: c:I - 48
|
||||
if c > 9: (c - 7) c
|
||||
|
||||
defn luhn?(cc):
|
||||
map(mul cc:digits:reverse [1 2]:cycle)
|
||||
.map(\(I(_ / 10) + (_ % 10))):sum
|
||||
.mod(10):zero?
|
||||
Loading…
Reference in New Issue