Created
May 9, 2015 04:10
-
-
Save SwipeX/656314da51413e6e2a5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
psuedo-code for calculating the max-depth of overlayed rectangles. | |
Members: Tim Dekker, Ryan Serva, Krzysztof Czerwinski | |
Map<Rectangle, Integer> depth; | |
public static void main(String[] args) throws FileNotFoundException { | |
int count = first int | |
//read in all rectangles and process them | |
for (int i = 0; i < count; i++) { | |
String line = next line | |
String[] data = line.split(","); | |
Rectangle rectangle = new Rectangle(data[0], data[1], data[2], data[3]); | |
processRectangle(rectangle); | |
} | |
//find max depth | |
int max = -1; | |
for (Entry <Rectangle, Integer> entry : depth.set()) { | |
int temp = entry.value | |
if (temp > max) | |
max = temp; | |
} | |
//max should be our output | |
} | |
processRectangle(Rectangle rectangle) { | |
for (Rectangle r : depth.keys()) { | |
if (r.contains(rectangle) || rectangle.contains(r)) { | |
depth.put(r, depth.get(r) + 1); | |
} | |
} | |
depth.put(rectangle, 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment