⍝ ⍵ similar integers, which sum to ⍺:

    100 nicediv 7           ⍝ 7 similar integers, which sum to 100.
14 15 14 14 14 15 14

    ↑ (0 to 10)nicediv¨5    ⍝ cols sum to 0 .. 10
0 0 0 0 0
0 0 1 0 0
0 1 0 1 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 1
1 1 2 1 1
1 2 1 2 1
2 1 2 1 2
2 2 1 2 2
2 2 2 2 2

    stack ← {⍉↑( ⍺ nicediv ⍵)/¨'⎕'}     ⍝ stacks ⍺ toy bricks into ⍵ columns.

    ⊖⎕fmt 100 stack¨ 12 23 39           ⍝ 100 bricks in various col widths.
  ⎕  ⎕  ⎕  ⎕                                                                    
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕                                                                   
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕                                                                   
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕                                                                   
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕   ⎕  ⎕  ⎕  ⎕ ⎕  ⎕  ⎕  ⎕                                           
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕                                          
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕ ⎕ ⎕ ⎕⎕ ⎕ ⎕ ⎕ ⎕⎕ ⎕ ⎕ ⎕⎕ ⎕ ⎕ ⎕ ⎕⎕ ⎕ ⎕ ⎕ 
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ 
 ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕  ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕ 

    {∧/⍵∧.=⍵∘.{+/⍺ nicediv ⍵}⍵}⍳50      ⍝ check that: ⍺ = +/ ⍺ nicediv ⍵
1

⍝∇ nicediv to

Back to: code

Back to: Workspaces