#APL NARS 90 chars r←f w;i;h r←⍬⋄i←1⋄→0×⍳0≠⍴⍴w⋄→0×⍳''≡0↑w⋄→0×⍳w≠⌊w A:i+←1⋄→A×⍳∼0=i∣w⋄→0×⍳i>h←w÷i⋄r←r,⊂i h⋄→A 9+37+41+3=90 Test: (where print nothing, it return something, it return ⍬ the list null one has to consider as "no solution") f 101 f 1 2 3 f '1' f '123' f 33 1.23 f 1.23 ⎕←⊃f 16777216 2 8388608 4 4194304 8 2097152 16 1048576 32 524288 64 262144 128 131072 256 65536 512 32768 1024 16384 2048 8192 4096 4096 f 123 3 41