Created
May 7, 2015 05:21
-
-
Save SwipeX/f5d1a1c8d751c42115d8 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
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.FileNotFoundException; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Scanner; | |
/** | |
* @author Tim Dekker | |
* @since 5/7/15 | |
*/ | |
public class Application { | |
static HashMap<Rectangle, Integer> depth = new HashMap<Rectangle, Integer>(); | |
public static void main(String[] args) throws FileNotFoundException { | |
Scanner scanner = new Scanner(new FileInputStream(new File("./src/test"))); | |
int count = Integer.parseInt(scanner.nextLine()); | |
for (int i = 0; i < count; i++) { | |
String line = scanner.nextLine(); | |
String[] data = line.split(","); | |
Rectangle rectangle = new Rectangle(data[0], data[1], data[2], data[3]); | |
processRectangle(rectangle); | |
} | |
int max = -1; | |
for (Map.Entry<Rectangle, Integer> entry : depth.entrySet()) { | |
int temp = entry.getValue(); | |
if (temp > max) | |
max = temp; | |
} | |
System.out.println(max); | |
} | |
private static void processRectangle(Rectangle rectangle) { | |
for (Rectangle r : depth.keySet()) { | |
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