[Jprogramming] Ullman's Puzzle

Devon McCormick devonmcc at gmail.com
Thu Jan 6 00:10:53 HKT 2011


You may want to make the algorithm more palatable to a general audience by
assigning names to the items and using those, e.g.

NB.* Ullman: return 1 if "t" items of list sum to less than or equal to "k".
Ullman=: 3 : 0
   't k lst'=. y
   t > +/ k{. /:~ lst
NB.EG Ullman 98.2; 3; 18.1 55.1 91.2 74.6 73 85.9 73.9 81.4 87.1 49.3 88.8
5.7
)

Also, as seen above, it wouldn't hurt to include a comment or two to explain
what this does and give an example of how to use it.

On Wed, Jan 5, 2011 at 7:56 AM, Raul Miller <rauldmiller at gmail.com> wrote:

> On Tue, Jan 4, 2011 at 2:41 PM, Tikkanz <tikkanz at gmail.com> wrote:
> > ({.x) > +/ ({:x) {. /:~ y
>
> Which leads to a tacit {.@[ > {:@[ +/@{. /:~@]
>
> Which is not too bad, though perhaps not
> appropriate to that audience.
>
> --
> Raul
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail


More information about the Programming mailing list