September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,7 @@
# ncols is the number of columns (i.e. vertical poles)
def column_sums(ncols):
. as $abacus
| reduce range(0; ncols) as $col
([];
. + [reduce $abacus[] as $row
(0; if $row > $col then .+1 else . end)]) ;

View file

@ -0,0 +1,8 @@
# Generic function to count the number of items in a stream:
def count(stream): reduce stream as $i (0; .+1);
def readout:
. as $sums
| .[0] as $n
| reduce range(0;$n) as $i
([]; . + [count( $sums[] | select( . > $i) )]);

View file

@ -0,0 +1 @@
def bead_sort: column_sums(max) | readout;

View file

@ -0,0 +1 @@
[734,3,1,24,324,324,32,432,42,3,4,1,1] | bead_sort

View file

@ -0,0 +1,2 @@
$ jq -n -c -f bead_sort.jq
[734,432,324,324,42,32,24,4,3,3,1,1,1]