Created
May 7, 2015 05:21
Revisions
-
SwipeX created this gist
May 7, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ 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); } }