"Combinatorial Methods"11 바이트로 개선 :
9Bṁ×ḶṚÆ¡‘Œ?
온라인으로 사용해보십시오!
어떻게?
순열 계산과 계승 시스템을 사용합니다.
9Bṁ×ḶṚÆ¡‘Œ? - Link n e.g. 16
9B - nine in binary [1,0,0,1]
ṁ - mould like n [1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1]
Ḷ - lowered range(n) [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
× - multiply [0,0,0,3,4,0,0,7,8,0,0,11,12,0,0,15]
Ṛ - reverse [15,0,0,12,11,0,0,8,7,0,0,4,3,0,0,0]
Æ¡ - convert from factorial base 19621302981954 (=15*15!+12*12!+...+3*3!)
‘ - increment 19621302981955 (we actually wanted 1*0! too)
Œ? - shortest permutation of natural numbers [1,2,...] that would reside at that
- index in a sorted list of all permutations of those same numbers
- [16,1,2,15,14,3,4,13,12,5,6,11,10,7,8,9]
12 인치 "편직 패턴"개선 :
RṚ‘żRs2Z€FḊṁ
온라인으로 사용해보십시오!
어떻게?
이것은 간단한 접근 방식으로 두 가닥을 만들어 인터리브 한 다음 느슨한 끝을 자릅니다.
RṚ‘żRs2Z€FḊṁ - Link: n e.g. 8
R - range(n) [1,2,3,4,5,6,7,8]
Ṛ - reverse [8,7,6,5,4,3,2,1]
‘ - increment [9,8,7,6,5,4,3,2]
R - range(n) [1,2,3,4,5,6,7,8]
ż - zip (interleave) [[9,1],[8,2],[7,3],[6,4],[5,5],[4,6],[3,7],[2,8]]
s2 - split into chunks of length 2 [[[9,1],[8,2]],[[7,3],[6,4]],[[5,5],[4,6]],[[3,7],[2,8]]]
Z€ - transpose €ach (cross-stitch?!) [[[9,8],[1,2]],[[7,6],[3,4]],[[5,4],[5,6]],[[3,2],[7,8]]]
F - flatten [9,8,1,2,7,6,3,4,5,4,5,6,3,2,7,8]
Ḋ - dequeue (removes excess start) [8,1,2,7,6,3,4,5,4,5,6,3,2,7,8]
ṁ - mould like n (removes excess end) [8,1,2,7,6,3,4,5]