mine:

NB. from http://www.jsoftware.com/pipermail/chat/2013-October/005405.html
c=: 0 1{~((#x)#2)#:i.2^#x
d=: (150 = c+/ .*x)#c
smoutput pt1=:# d

min=: <./ +/"1 d
smoutput pt2=: +/ min = +/"1 d

On Thu, Dec 17, 2015 at 9:47 AM, 'Pascal Jasmin' via Programming
<[email protected]> wrote:
>
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to