Here's a funny--and much faster--one:
p=.p:i.n
*./"1 (*/p) = (*/"2 ,. */"1) q{p
Actually, I suppose it is better to do it with addition, so
p=.2^i.n
*./"1 (+/p) = (+/"2 ,. +/"1) q{p
Marshall
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Roger Hui
Sent: Monday, October 04, 2010 6:41 PM
To: Programming forum
Subject: [Jprogramming] Distinct Numbers in Rows and Columns
An interesting puzzle arising from the KenKen solver:
q is an array with shape (m,n,n) and (,q) e. 1+i.n .
Which items of q have 1+i.n in each row and in each column?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm