[Jprogramming] J expression question

Glenn M. Lewis glenn at hometot.com
Sat Jun 30 12:36:19 HKT 2007


I apologize for replying to my own message, but I just realized that I 
must choose to either maximize the columns or maximize the rows... not 
both.  So let's say I wish to maximize the columns.  It appears that the 
three tied answers are still valid.
Thanks again!
-- Glenn

Glenn M. Lewis wrote:

> Hi all!
>
>    Say I have a table with shape 'm n'  (m rows, n columns) populated 
> with ones and zeros.
>
>    Let's say I would like to create the largest table possible by 
> selecting the most rows and the most columns where all intersections 
> of said rows and columns consist of all ones.
>
>    I'm having difficulties coming up with an expression that gives me 
> two lists... one for the rows and one for the columns that 'selects' 
> the rows/columns that would make up this maximal table.
>
>    Wow... I probably didn't explain that very well.   Let me try an 
> example.
>
>   t =. 6 10 $ 0 1 1 0 0 1
>   t
> 0 1 1 0 0 1 0 1 1 0
> 0 1 0 1 1 0 0 1 0 1
> 1 0 0 1 0 1 1 0 0 1
> 0 1 1 0 0 1 0 1 1 0
> 0 1 0 1 1 0 0 1 0 1
> 1 0 0 1 0 1 1 0 0 1
>
>    By inspection, it appears that one of three solutions is possible 
> that all tie for the maximum-sized table of all-ones (in this case, a 
> shape '2 5' table.
> rows 0 and 3 with columns 1,2,5,7,8  or in J:
>
>   (< 0 3 ; 1 2 5 7 8) { t
> 1 1 1 1 1
> 1 1 1 1 1
>
> or
>
>   (< 1 4 ; 1 3 4 7 9) { t
> 1 1 1 1 1
> 1 1 1 1 1
>
> or
>
>   (< 2 5 ; 0 3 5 6 9) { t
> 1 1 1 1 1
> 1 1 1 1 1
>
>    The problem I'm having is coming up with these lists 
> algorithmically...
>
>    Any ideas on how to solve this?
>
>    Thanks!
> -- Glenn Lewis
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
>


More information about the Programming mailing list