果冻,10个程序,65字节
Ṣ
¹Þ
Ụị
Œ!Ṃ
7778Ọv
Ẋ>2\S$¿
ĠFḣṪ¥@€
~Ṁ~rṀxLœ&
C»/ð+ÆNPÆfÆC_ḷ
<þḅ1‘WiþJḄ³ṫZḢ
@Lynn的Jelly答案有一些不可避免的重叠。她对bogosort的想法功不可没。
在线尝试!或验证唯一性。
他们如何工作
Ṣ Main link. Argument: A (array)
Ṣ Sort A.
¹Þ Main link. Argument: A (array)
¹Þ Sort A, using the identity function as the key.
Ụị Main link. Argument: A (array)
Ụ Grade up; yield all indices of A, sorted by their corr. values.
ị Index into A.
Œ!Ṃ Main link. Argument: A (array)
Œ! Yield all permutations of A.
Ṃ Minimum; yield the lexicographically smallest permutation.
7778Ọv Main link. Argument: A (array)
7778Ọ Unordinal; yield chr(7778) = 'Ṣ'.
v Evaluate with argument A.
Ẋ>2\S$¿ Main link. Argument: A (array)
¿ While the condition it truthy, execute the body.
>2\S$ Condition:
$ Combine the two links to the left into a monadic chain.
>2\ Perform pairwise greater-than comparison.
S Sum; add the results.
This returns 0 iff A contains an unsorted pair of integers.
Ẋ Body: Shuffle A.
ĠFḣṪ¥@€ Main link. Argument: A (array)
Ġ Group the indices of A by their sorted values.
F Flatten the result.
€ Apply the link to the left to each index in the previous result,
calling it with the index as left argument and A as the right one.
¥@ Combine the two links to the left into a dyadic chain and swap
its arguments, so A is left one and the index i is the right one.
ḣ Head; take the first i elements of A.
Ṫ Tail; yield the last of the first i, i.e., the i-th element of A.
~Ṁ~rṀxLœ& Main link. Argument: A (array)
~ Take the bitwise NOT of all integers in A.
Ṁ Take the maximum.
~ Take the bitwise NOT of the maximum, yielding the minimum of A.
Ṁ Yield the maximum of A.
r Range; yield [min(A), ... max(A)].
L Yield the length of A.
x Repeat each integer in the range len(A) times.
œ& Take the multiset-intersection of the result and A.
C»/ð+ÆNPÆfÆC_ḷ Main link. Argument: A (array)
C Complement; map (x -> 1-x) over A.
»/ Reduce by dyadic maximum, yielding 1-min(A).
ð Begin a new, dyadic chain. Arguments: 1-min(A), A
+ Add 1-min(A) to all elements of A, making them strictly positive.
ÆN For each element n of the result, yield the n-th prime number.
P Take the product.
Æf Factorize the product into prime numbers, with repetition.
ÆC Prime count; count the number of primes less than or equal to p,
for each prime p in the resulting factorization.
ḷ Yield the left argument, 1-min(A).
_ Subtract 1-min(A) from each prime count in the result to the left.
<þḅ1‘WiþJḄ³ṫZḢ Main link. Argument: A (array)
<þ Construct the less-than matrix of all pairs of elements in A.
ḅ1 Convert each row from base 1 to integer (sum each).
‘ Increment. The integer at index i now counts how many elements
of A are less than or equal to the i-th.
W Wrap the resulting 1D array into an array.
J Yield the indices of A, i.e., [1, ..., len(A)].
iþ Construct the index table; for each array T in the singleton array
to the left and index j to the right, find the index of j in T.
This yields an array of singleton arrays.
Ḅ Unbinary; convert each singleton from base 2 to integer, mapping
([x]-> x) over the array.
³ Yield A.
ṫ Tail; for each integer i in the result of `Ḅ`, create a copy of A
without its first i-1 elements.
Z Zip/transpose. The first column becomes the first row.
Ḣ Head; yield the first row.