Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,18 @@
# Sort any array
def selection_sort:
def swap(i;j): if i == j then . else .[i] as $tmp | .[i] = .[j] | .[j] = $tmp end;
length as $length
| reduce range(0; $length) as $currentPlace
# state: $array
( .;
. as $array
| (reduce range( $currentPlace; $length) as $check
# state: [ smallestAt, smallest] except initially [null]
( [$currentPlace+1] ;
if length == 1 or $array[$check] < .[1]
then [$check, $array[$check] ]
else .
end
)) as $ans
| swap( $currentPlace; $ans[0] )
) ;

View file

@ -0,0 +1 @@
[1, 3.3, null, 2, null, [1,{"a":1 }] ] | selection_sort