This is just an x,y graph that have on/off cells, either 1 or 0, where the 'on' cells create rectangles. Think sort of like the game battleship.
Example:
1,1,0,0,0,0,1,1,1
1,1,0,0,0,0,1,1,1
0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,1,0,0
1,1,1,1,1,1,1,0,0
0,0,0,0,0,0,0,0,1
This has 4 rectangles in it. The key to this is that the rectangles do not touch or overlap, so there are 0's (or the edge) around them.

Actually, a point to be made, in Java at least, it is set up as y,x coordinates. The points of the graph are:
[0,0],[0,1],[0,2],[0,3] etc...
[1,0],[1,1],[1,2],[1,3] etc...
[2,0],[2,1],[2,2],[2,3] etc..
etc..,etc..,etc..,etc...
So in the starting code, you could output a value like this:

System.out.print(a1[3,1]);// 4 actual rows down, 2 actual columns over (counts start at 0)

Before I asked the question, I plotted all these out on a graph. The written out 2D array is the reflection (on the x plane) of the plotted graph. What stumped me is that a single point counts as a rectangle which was what was throwing me off originally.

This task was easier than the Armstrong numbers task. That one took me the better part of 2 weeks, and i recruited 2 friends who are professional programmers for help, but ya, I had to do the same thing with plotting things out... and the reverse x,y thing threw me off for a bit too.

Sure.
I don't know if you have figured this out yet, but if delete the last curly bracket (the closing one fore the Solution class) then add it right back, IntelliJ will properly format you code, e.g. add space, new lines, indentation. Sometimes my code gets a little sloppy when I am first trying to solve something, with adding and deleting code, but I do this alot to quickly clean things up. Take this code for example:

Please could you explai more how you get this for rectangle in your example ??? :
1,1,0,0,0,0,1,1,1
1,1,0,0,0,0,1,1,1
0,0,0,0,0,0,0,0,0
1,1,1,1,1,1,1,0,0
1,1,1,1,1,1,1,0,0
0,0,0,0,0,0,0,0,1
This has 4 rectangles in it. The key to this is that the rectangles do not touch or overlap, so there are 0's (or the edge) around them.

0

This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.

4 rectangles in it. The key to this is that the rectangles do not touch or overlap, so there are 0's (or the edge) around them.