combT =: ([: ; ([ ; [: i.@>: -~) ((1 {:: [) ,.&.> [: ,&.>/\. >:&.>@:])^:(0 {:: 
[) (<i.1 0),~ (< i.0 0) $~ -~)

a =. ". > cutLF wdclippaste ''
4 5 6 7 8 +/@:(150 = a +/@:{~"1 combT )"(0)  20

(itemized results that give solution to part2 as well.)

these versions do it without comb

a  +/@:((150 = +/@:#~)"1) (20#2) #: i. 2^20
a  +/@:(150 = +/"1@:(#~ ( #~  (9&> *.  3&<)@(+/"1)))) (20#2) #: i. 2^20
a +/@:(150 = +/"1@:(#~ ( #~ (4&=)@(+/"1)))) (20#2) #: i. 2^20
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to