[Jprogramming] Another Problem to Sharpen J Skills
Raul Miller
rauldmiller at gmail.com
Fri Sep 1 07:21:29 UTC 2017
If it exists, >./([-.-.)/a will find the largest integer common to all
of the rows. (If it does not exist, it will give you __ which is the
identity element for "largest". In other words, __ >. x always returns
x).
To get the smallest replace >. with <.
In other words, first find the intersection of all rows, then find the
largest (or smallest) number in that intersection.
Thanks,
--
Raul
On Fri, Sep 1, 2017 at 2:48 AM, Skip Cave <skip at caveconsulting.com> wrote:
> This wasn't a Quora problem, though I needed to solve this as part of the
> solution to a different problem.
>
> Given the random integer matrix:
>
> ]a =: 6 12$ ?72$10
>
> 2 3 6 6 5 8 3 7 4 9 0 8
>
> 1 9 4 1 7 3 1 8 2 5 2 7
>
> 4 7 4 7 6 4 1 1 4 6 6 8
>
> 5 8 0 0 3 1 8 3 0 7 3 3
>
> 4 4 7 3 2 4 7 5 7 3 3 9
>
> 3 8 4 1 3 7 8 7 5 6 9 9
>
>
> What J expression will find the largest integer that is common to all
>
> of the rows? In this specific case, the answer is 7.
>
> What about the smallest integer that's common in all rows?
>
>
> Skip
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list