| Bytes | Lang | Time | Link |
|---|---|---|---|
| 144 | Wolfram Language Mathematica | 250625T151230Z | Domenico |
| 020 | Jelly | 250626T000602Z | Jonathan |
| 076 | Charcoal | 250625T211919Z | Neil |
| 173 | JavaScript ES10 | 250625T212013Z | Arnauld |
Wolfram Language (Mathematica), 182 144 bytes
r=Range;v=Reverse@*Flatten
a_~g~b_:=SortBy[v@l,a[[#]]&][[b]]
f@n_:={}⋃g@@@v[v/@{#,v@#}&/@{#,v/@#}&/@{l=r@#+#(#-1)/2&/@r@n,l~v~{2}},2]~Tuples~2
Just the direct approach
Jelly, 20 bytes
R€UZ$NƭƬ;Ṛ€$F€Ụ€Q;U$
A monadic Link that accepts a positive integer (works for \$<4\$), and yields a list of the permutations.
How?
Build fourteen triangles of integers that represent half (i.e. eleven, with some repetition) of the final permutations; grade them to get the permutations; add the reverse of these to complete the set with the other eleven:
R€UZ$NƭƬ;Ṛ€$F€Ụ€Q;U$ - Link: positive integer, N
R€ - range of each of [1..N] -> [[1],[1,2],[1,2,3],...,[1..N]
Ƭ - collect until a fixed point under:
ƭ - alternate between:
UZ$ - a) reverse each then transpose
N - b) negate all elements
-> e.g. N=4:
[[[ 1], [ 1, 2], [ 1, 2, 3], [ 1, 2, 3, 4]],
[[ 1, 2, 3, 4], [ 1, 2, 3], [ 1, 2], [ 1]],
[[-1,-2,-3,-4], [-1,-2,-3], [-1,-2], [-1]],
[[-4,-3,-2,-1], [-3,-2,-1], [-2,-1], [-1]],
[[ 4, 3, 2, 1], [ 3, 2, 1], [ 2, 1], [ 1]],
[[ 1, 1, 1, 1], [ 2, 2, 2], [ 3, 3], [ 4]],
[[-1,-1,-1,-1], [-2,-2,-2], [-3,-3], [-4]]]
;Ṛ€$ - concatenate reverse of each (N.B.: U would reverse sublists)
F€ - flatten each
-> e.g. N=4:
[[ 1, 1, 2, 1, 2, 3, 1, 2, 3, 4],
[ 1, 2, 3, 4, 1, 2, 3, 1, 2, 1],
[-1,-2,-3,-4,-1,-2,-3,-1,-2,-1],
[-4,-3,-2,-1,-3,-2,-1,-2,-1,-1],
[ 4, 3, 2, 1, 3, 2, 1, 2, 1, 1],
[ 1, 1, 1, 1, 2, 2, 2, 3, 3, 4],
[-1,-1,-1,-1,-2,-2,-2,-3,-3,-4],
[ 1, 2, 3, 4, 1, 2, 3, 1, 2, 1],
[ 1, 1, 2, 1, 2, 3, 1, 2, 3, 4],
[-1,-1,-2,-1,-2,-3,-1,-2,-3,-4],
[-1,-2,-1,-3,-2,-1,-4,-3,-2,-1],
[ 1, 2, 1, 3, 2, 1, 4, 3, 2, 1],
[ 4, 3, 3, 2, 2, 2, 1, 1, 1, 1],
[-4,-3,-3,-2,-2,-2,-1,-1,-1,-1]]
Ụ€ - grade each (1-indices ordered by values)
-> e.g. N=4:
[[ 1, 2, 4, 7, 3, 5, 8, 6, 9,10], (a)
[ 1, 5, 8,10, 2, 6, 9, 3, 7, 4], (b)
[ 4, 3, 7, 2, 6, 9, 1, 5, 8,10],
[ 1, 2, 5, 3, 6, 8, 4, 7, 9,10],
[ 4, 7, 9,10, 3, 6, 8, 2, 5, 1],
[ 1, 2, 3, 4, 5, 6, 7, 8, 9,10], (c)
[10, 8, 9, 5, 6, 7, 1, 2, 3, 4],
[ 1, 5, 8,10, 2, 6, 9, 3, 7, 4], (dupe of b)
[ 1, 2, 4, 7, 3, 5, 8, 6, 9,10], (dupe of a)
[10, 6, 9, 3, 5, 8, 1, 2, 4, 7],
[ 7, 4, 8, 2, 5, 9, 1, 3, 6,10],
[ 1, 3, 6,10, 2, 5, 9, 4, 8, 7],
[ 7, 8, 9,10, 4, 5, 6, 2, 3, 1],
[ 1, 2, 3, 4, 5, 6, 7, 8, 9,10]] (dupe of c)
Q - deduplicate
;U$ - concatenate reverse of each
mpjheuoicsgdgitemshfairealipepitrycadchnhesiddecipheringmethodsarehighlyspecificimjustapad
Charcoal, 79 76 bytes
≔⟦⟦⁰⟧⟧θF⊖N⊞θE⊕Lθ⁺LΣθκF³«F⟦θ⮌θ⟧⊞⊞OυΣκ⮌Σκ≔⮌E⮌θ⮌Eκ§§⮌θνλθ»≔ΣEυEυEι⌕λνυ⭆¹Φυ⁼μ⌕υλ
Attempt This Online! Link is to verbose version of code. Explanation:
≔⟦⟦⁰⟧⟧θF⊖N⊞θE⊕Lθ⁺LΣθκ
Create the initial triangle.
F³«
Prepare to read it in three directions.
F⟦θ⮌θ⟧⊞⊞OυΣκ⮌Σκ
Read it forwards, backwards, up and down.
≔⮌E⮌θ⮌Eκ§§⮌θνλθ»
Rotate the triangle.
≔ΣEυEυEι⌕λνυ
Get all of the 144 transpositions.
⭆¹Φυ⁼μ⌕υλ
Output only those that are unique.
JavaScript (ES10), 173 bytes
Returns a set of comma-separated strings. Values are 0-indexed.
There's probably a significantly shorter way with smarter math.
n=>new Set([...(g=i=>{for(a=[],r=n;r--;)for(x=y=i&2?n-r:r+1;x--;)a.push((X=i&1?y+~x:x,Y=n+~X,i<4?n-y:y+~X)-Y*~Y/2)})+0].map((_,i)=>g(i&7)||a.map(v=>a.indexOf(v),g(i/8))+""))