Ḷc€`Ṣ€Fḟ0ị@
在线尝试!
取索引并返回整数的单子链接-使用基于1的索引。
怎么样?
正好按照编写的方式执行挑战,只是将Pascal三角形的右边(零)中的更多部分丢掉了……
Ḷ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 --------------^