I did develop further the "multiple item Power" function I brought up earlier 
to solve a semihard problem.  A write up is here.

http://www.jsoftware.com/jwiki/PascalJasmin/Single%20line%20path%20searching%20frameworks


But I pose a challenge:

consider these 6 grids:

0 0 1 1 1 1 
0 0 1 1 1 1 
0 0 1 1 1 1 
0 0 1 1 1 1 
0 1 1 1 0 1 
0 0 0 0 0 1 

0 0 1 1 1 1 
0 0 0 0 1 1 
0 0 0 0 0 1 
1 0 0 0 0 1 
1 1 1 1 1 1 
1 1 1 1 1 1 

0 0 1 1 1 1 
0 0 1 1 1 1 
0 0 0 1 1 1 
1 1 0 0 0 0 
1 1 1 1 0 0 
1 1 1 0 0 1 

0 0 1 1 1 1 
0 0 1 1 0 0 
0 0 0 1 0 0 
1 1 0 0 0 0 
1 1 1 1 1 1 
1 1 1 1 1 1 

0 0 0 0 0 1 
0 0 1 1 0 1 
0 0 0 0 0 1 
1 0 0 1 1 1 
1 1 1 1 1 1 
1 1 1 1 1 1 

0 0 1 1 1 1 
0 0 0 0 1 0 
0 0 0 0 0 0 
1 0 0 1 1 1 
1 1 1 1 1 1 
1 1 1 1 1 1 



The first 2 are "connected" because all of the 1s form a single continuous 
island.  The last 4 are not connected because there are more than a single 
continuous island of 1s.

Can you write a function that returns 1 if a grid is connected, 0 otherwise?

An easier way to load the data for each of the grids.

6 6$0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 1 
6 6$0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 
6 6$0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 1 0 0 1 1 1 0 0 1 
6 6$0 0 1 1 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 
6 6$0 0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
6 6$0 0 1 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to