Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/Van-Eck-sequence/Jq/van-eck-sequence-1.jq
Normal file
19
Task/Van-Eck-sequence/Jq/van-eck-sequence-1.jq
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Input: an array
|
||||
# If the rightmost element, .[-1], does not occur elsewhere, return 0;
|
||||
# otherwise return the "depth" of its rightmost occurrence in .[0:-2]
|
||||
def depth:
|
||||
.[-1] as $x
|
||||
| length as $length
|
||||
| first(range($length-2; -1; -1) as $i
|
||||
| select(.[$i] == $x) | $length - 1 - $i)
|
||||
// 0 ;
|
||||
|
||||
# Generate a stream of the first $n van Eck integers:
|
||||
def vanEck($n):
|
||||
def v:
|
||||
recurse( if length == $n then empty
|
||||
else . + [depth] end );
|
||||
[0] | v | .[-1];
|
||||
|
||||
# The task:
|
||||
[vanEck(10)], [vanEck(1000)][990:1001]
|
||||
2
Task/Van-Eck-sequence/Jq/van-eck-sequence-2.jq
Normal file
2
Task/Van-Eck-sequence/Jq/van-eck-sequence-2.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[0,0,1,0,2,0,2,2,1,6]
|
||||
[4,7,30,25,67,225,488,0,10,136]
|
||||
Loading…
Add table
Add a link
Reference in a new issue