Raul's nice use of toupper can simplify my first effort:

   c=: ;: ' ' I.@(=toupper)@]} tolower fread '~temp/c.txt'
   d=: (\:n){(~.c) (,' ',":@]) each n=. #/.~ c
   (;d,each '|') fwrite 'solution.txt'
11608

   fread 'solution.txt';0 80
the 727|of 495|shall 306|and 264|to 202|be 179|or 160|in 147|states
129|presiden

Note that this solution adheres to the I/O requirements of the challenge.


On 26 January 2016 at 21:15, Raul Miller <[email protected]> wrote:

> I guess I'd be inclined to do it like this:
>
> require'web/gethttp'
> const=: gethttp 'http://usconstitution.net/const.txt'
> words=: [: ;: ' '"_`(I.@:= toupper)`]}~@tolower
>
>    \:~ (<@#/.~,.~.)words const
> +---+-----+
> |727|the  |
> +---+-----+
> |495|of   |
> +---+-----+
> |306|shall|
> +---+-----+
> |264|and  |
> +---+-----+
> |202|to   |
> ...
>
> Though of course, it's possible to format that result differently.
>
> Thanks,
>
> --
> Raul
>
>
>
> On Tue, Jan 26, 2016 at 5:29 PM, Roger Hui <[email protected]>
> wrote:
> >
> http://kxcommunity.com/kx-student-programming-challenge-us-constitution-word-count.php
> >
> > J solution, anyone?
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> 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