[Jprogramming] a simple problem?

Dan Bron j at bron.us
Fri Sep 14 08:39:28 HKT 2007


Christopher,

There are several ways to get the result you want.  I would probably use the rank conjunction:

	   A =: ".;._2 noun define
	     2 1
	     2 2
	     1 3
	     2 1
	     2 1
	     1 2
	     1 1
	)
	
	
	   B =: ".;._2 noun define
	     1 1
	     1 2
	     1 3
	     2 1
	     2 2
	     2 3
	)
	
	   NB.  R is your desired result
	   R =: ".;._2 noun define
	     0 0 0 1 0 0
	     0 0 0 0 1 0
	     0 0 1 0 0 0
	     0 0 0 1 0 0
	     0 0 0 1 0 0
	     0 1 0 0 0 0
	     1 0 0 0 0 0
	)
	
	
	   A -:"1"1 _ B
	0 0 0 1 0 0
	0 0 0 0 1 0
	0 0 1 0 0 0
	0 0 0 1 0 0
	0 0 0 1 0 0
	0 1 0 0 0 0
	1 0 0 0 0 0
	

	   NB.  yep, the result you wanted.
	   R -: A -:"1"1 _ B
	1
	   
If others post different solutions, you should compare all the time-and-space metrics (with  6!:2  and  7!:2  ) and pick the
fastest, leanest solution.

-Dan



More information about the Programming mailing list