Could someone explain please?
I don't understand this task at all.
Resolved
Comments (9)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
18 March 2019, 18:19
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.
+1
Guadalupe Gagnon
18 March 2019, 18:27
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:
which would output 0,
0
Andrew
18 March 2019, 19:24solution
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.
+3
Guadalupe Gagnon
18 March 2019, 19:32
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.
+1
Andrew
19 March 2019, 17:16
My solution is really messy (I think). Could you PM me yours so I can compare and attempt to make mine more elegant?
0
Guadalupe Gagnon
19 March 2019, 17:27
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:
when i do what i described above it turns it into this:
This works for any closing curly bracket and the code contained within. I always use the last one to clean up all my code. +3
Andrew
19 March 2019, 19:41
Cool tip, thanks!
0
Josephine
2 February 2021, 20:42
so 0 0
0 1 count as a rectangle
And 0 1
0 1 count as a rectangle.
Am i right.
+1
Banak
20 February 2021, 16:50
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