aboutsummaryrefslogtreecommitdiff
path: root/challenge-067/richard-park/apl/NumberCombinations.aplf
blob: 5f7ad35d221fe07bbc93dfe823db4e6cf8466c98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
 NumberCombinations{
⍝ ←: All strictly ascending vectors of length ⍵ 
⍝    which contain numbers in ⍳⍺
⍝ Attempt 1
⍝ =========
     c,(()∘.,⊢)(¯1+)⊢⍳       ⍝ All combinations of digits in (⍳⍺)
                                   ⍝ Of length ⍵
     c⌿⍨{((∪≡⊢))((⊂⍋))}¨c   ⍝ Strictly ascending combinations
⍝ Attempt 2
⍝ =========
⍝ e.g. 5 NumberCombinations 2
     a¯1+   
     b(¯1+)⍴⊂a     ⍝ Maximal run repeated ¯1+⍺ times
     c1+0~⍨¨b×ab   ⍝ Remove 0s and add 1
     ⊃,/a,¨¨c        ⍝ Catenate a's with c's 
 }