diff --git a/uil/october-2013/12/bin/CheckerBoard.class b/uil/october-2013/12/bin/CheckerBoard.class index 29d720b..d5d7e13 100644 Binary files a/uil/october-2013/12/bin/CheckerBoard.class and b/uil/october-2013/12/bin/CheckerBoard.class differ diff --git a/uil/october-2013/12/bin/Point.class b/uil/october-2013/12/bin/Point.class index 9870b42..02dd111 100644 Binary files a/uil/october-2013/12/bin/Point.class and b/uil/october-2013/12/bin/Point.class differ diff --git a/uil/october-2013/12/bin/problem12.class b/uil/october-2013/12/bin/problem12.class index 919a8e1..3ad2184 100644 Binary files a/uil/october-2013/12/bin/problem12.class and b/uil/october-2013/12/bin/problem12.class differ diff --git a/uil/october-2013/12/src/problem12.java b/uil/october-2013/12/src/problem12.java index 0303806..75454cb 100644 --- a/uil/october-2013/12/src/problem12.java +++ b/uil/october-2013/12/src/problem12.java @@ -1,7 +1,6 @@ import static java.lang.System.*; import java.io.File; import java.io.FileNotFoundException; -import java.util.Arrays; import java.util.List; import java.util.ArrayList; import java.util.Scanner; @@ -31,7 +30,8 @@ class Point { Point merge(Point other) { return new Point(this.x + other.x, this.y + other.y, this.type); } - + + // Offsets the point by a Point's (x, y) set void offset(Point other) { this.x += other.x; this.y += other.y; @@ -82,6 +82,7 @@ class Point { return -1; } + // Creates a List of Points based on a primitive int[][] matrix static List asList(int[][] primitivePoints) { List points = new ArrayList(); for (int[] primPoint: primitivePoints) { @@ -110,6 +111,7 @@ class CheckerBoard { } } + // toString method for a Checkerboard, prints a matrix of types public String toString() { String[] result = new String[this.matrix.length]; for(int x = 0; x < this.matrix.length; x++) { @@ -121,10 +123,13 @@ class CheckerBoard { return String.join("\n", result); } + // Simple functions for identifying whether a point is inBounds. private static boolean inBounds(Point point) {return CheckerBoard.inBounds(point.x, point.y);} private static boolean inBounds(int x, int y) {return x >= 0 && y >= 0 && x < 8 && y < 8;} + // Simple internal getter functions private Point getPoint(Point point) {return this.matrix[point.x][point.y];} String getType(Point point) {return this.matrix[point.x][point.y].type;} + // Identifies whether two points are opposite in types. R(ed) != B(lack) private boolean isReverse(Point first, Point second) {return (first.type.equals(team1) && second.type.equals(team2)) || (first.type.equals(team2) && second.type.equals(team1));} // Just returns all Points with type designated @@ -139,11 +144,14 @@ class CheckerBoard { return found; } + // Starter function for finding max jumps at a point. private int getMaxJumps(Point point) { List previous = new ArrayList(); previous.add(point); return getMaxJumps(point, 0, previous); } + + // Recursively finds maximum possible jumps at a point. private int getMaxJumps(Point point, int score, List previous) { List offsetScores = new ArrayList(); offsetScores.add(score);