Ḷc€`Ṣ€Fḟ0ị@
온라인으로 사용해보십시오!
인덱스를 가져와 정수를 반환하는 모나드 링크는 1 기반 인덱스를 사용합니다.
방법?
파스칼의 삼각형 (0)의 오른쪽을 더 많이 사용하여 버리면 거의 도전을 수행합니다 ...
Ḷc€`Ṣ€Fḟ0ị@ - Link: integer, i e.g. 1 or 9
Ḷ - lowered range [0] [0,1,2,3,4,5,6,7,8]
` - repeat left as right arg [0] [0,1,2,3,4,5,6,7,8]
c€ - binomial choice for €ach [[1]] [[1,0,0,0,0,0,0,0,0],[1,1,0,0,0,0,0,0,0],[1,2,1,0,0,0,0,0,0],[1,3,3,1,0,0,0,0,0],[1,4,6,4,1,0,0,0,0],[1,5,10,10,5,1,0,0,0],[1,6,15,20,15,6,1,0,0],[1,7,21,35,35,21,7,1,0],[1,8,28,56,70,56,28,8,1]]
Ṣ€ - sort €ach [[1]] [[0,0,0,0,0,0,0,0,1],[0,0,0,0,0,0,0,1,1],[0,0,0,0,0,0,1,1,2],[0,0,0,0,0,1,1,3,3],[0,0,0,0,1,1,4,4,6],[0,0,0,1,1,5,5,10,10],[0,0,1,1,6,6,15,15,20],[0,1,1,7,7,21,21,35,35],[1,1,8,8,28,28,56,56,70]]
F - flatten [1] [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,2,0,0,0,0,0,1,1,3,3,0,0,0,0,1,1,4,4,6,0,0,0,1,1,5,5,10,10,0,0,1,1,6,6,15,15,20,0,1,1,7,7,21,21,35,35,1,1,8,8,28,28,56,56,70]
ḟ0 - filter discard zeros [1] [1,1,1,1,1,2,1,1,3,3,1,1,4,4,6,1,1,5,5,111,1,6,6,15,15,21,1,7,7,21,21,35,35,1,1,8,8,28,28,56,56,70]
ị@ - index into (sw@p args) 1 3 --------------^