Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,23 @@
import sequtils
iterator castOut(base = 10, start = 1, ending = 999_999) =
var ran: seq[int] = @[]
for y in 0 .. <base-1:
if y mod (base - 1) == (y*y) mod (base - 1):
ran.add(y)
var x = start div (base - 1)
var y = start mod (base - 1)
block outer:
while true:
for n in ran:
let k = (base - 1) * x + n
if k < start:
continue
if k > ending:
break outer
yield k
inc x
echo toSeq(castOut(base=16, start=1, ending=255))

View file

@ -0,0 +1,6 @@
def co9:
def digits: tostring | explode | map(. - 48); # "0" is 48
if . == 9 then 0
elif 0 <= . and . <= 8 then .
else digits | add | co9
end;

View file

@ -0,0 +1 @@
def co9_equals_co9_squared: co9 == ((.*.)|co9);

View file

@ -0,0 +1 @@
[range (1;101) | select( co9_equals_co9_squared )

View file

@ -0,0 +1 @@
[ range(1;101) | select(is_kaprekar) ]

View file

@ -0,0 +1,3 @@
def verify:
range(1; .)
| select(is_kaprekar and (co9_equals_co9_squared | not));

View file

@ -0,0 +1,5 @@
def proportion(base):
def count(stream): reduce stream as $i (0; . + 1);
. as $n
| (base - 1) as $b
| count( range(1; 1+$n) | select( . % $b == (.*.) % $b) ) / $n ;

View file

@ -0,0 +1,5 @@
0.3
0.27
0.267
0.2667
0.26667