mirror of
https://github.com/Xevion/contest.git
synced 2025-12-06 13:14:39 -06:00
problem 12 final finsh
This commit is contained in:
35
uil/october-2013/12/.idea/workspace.xml
generated
35
uil/october-2013/12/.idea/workspace.xml
generated
@@ -2,12 +2,6 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1fd89a9c-d895-4e45-acab-398cb78a9403" name="Default Changelist" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bin/CheckerBoard.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bin/Point.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/bin/problem12.class" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/input.dat" beforeDir="false" afterPath="$PROJECT_DIR$/input.dat" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/problem12.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/problem12.java" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/bin/" />
|
||||
@@ -21,7 +15,7 @@
|
||||
<session id="1210997399">
|
||||
<usages-collector id="statistics.lifecycle.project">
|
||||
<counts>
|
||||
<entry key="project.closed" value="1" />
|
||||
<entry key="project.closed" value="2" />
|
||||
<entry key="project.open.time.4" value="1" />
|
||||
<entry key="project.open.time.6" value="1" />
|
||||
<entry key="project.opened" value="2" />
|
||||
@@ -42,12 +36,12 @@
|
||||
<usages-collector id="statistics.file.extensions.edit">
|
||||
<counts>
|
||||
<entry key="dat" value="127" />
|
||||
<entry key="java" value="2514" />
|
||||
<entry key="java" value="2680" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
<usages-collector id="statistics.file.types.edit">
|
||||
<counts>
|
||||
<entry key="JAVA" value="2514" />
|
||||
<entry key="JAVA" value="2680" />
|
||||
<entry key="PLAIN_TEXT" value="127" />
|
||||
</counts>
|
||||
</usages-collector>
|
||||
@@ -58,12 +52,15 @@
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/src/problem12.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="192">
|
||||
<caret line="147" column="24" selection-start-line="147" selection-start-column="24" selection-end-line="147" selection-end-column="24" />
|
||||
<state relative-caret-position="481">
|
||||
<caret line="150" column="29" lean-forward="true" selection-start-line="150" selection-start-column="29" selection-end-line="150" selection-end-column="29" />
|
||||
<folding>
|
||||
<element signature="e#4994#5001#0" expanded="true" />
|
||||
<element signature="e#739#740#0" expanded="true" />
|
||||
<element signature="e#807#808#0" expanded="true" />
|
||||
<element signature="e#3781#3788#0" expanded="true" />
|
||||
<element signature="e#4159#4166#0" expanded="true" />
|
||||
<element signature="e#4307#4316#0" expanded="true" />
|
||||
<element signature="e#5559#5568#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
@@ -136,7 +133,7 @@
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1569029426079" />
|
||||
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1569034632346" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="project.structure.last.edited" value="Project" />
|
||||
<property name="project.structure.proportion" value="0.15" />
|
||||
@@ -192,7 +189,6 @@
|
||||
</component>
|
||||
<component name="ToolWindowManager">
|
||||
<frame x="-8" y="-8" width="1936" height="1066" extended-state="6" />
|
||||
<editor active="true" />
|
||||
<layout>
|
||||
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25266525" />
|
||||
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
|
||||
@@ -203,7 +199,7 @@
|
||||
<window_info id="Favorites" order="6" side_tool="true" />
|
||||
<window_info anchor="bottom" id="Message" order="0" />
|
||||
<window_info anchor="bottom" id="Find" order="1" />
|
||||
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32939914" />
|
||||
<window_info anchor="bottom" id="Run" order="2" weight="0.32939914" />
|
||||
<window_info anchor="bottom" id="Debug" order="3" weight="0.39914164" />
|
||||
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
|
||||
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
|
||||
@@ -249,12 +245,15 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/problem12.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="192">
|
||||
<caret line="147" column="24" selection-start-line="147" selection-start-column="24" selection-end-line="147" selection-end-column="24" />
|
||||
<state relative-caret-position="481">
|
||||
<caret line="150" column="29" lean-forward="true" selection-start-line="150" selection-start-column="29" selection-end-line="150" selection-end-column="29" />
|
||||
<folding>
|
||||
<element signature="e#4994#5001#0" expanded="true" />
|
||||
<element signature="e#739#740#0" expanded="true" />
|
||||
<element signature="e#807#808#0" expanded="true" />
|
||||
<element signature="e#3781#3788#0" expanded="true" />
|
||||
<element signature="e#4159#4166#0" expanded="true" />
|
||||
<element signature="e#4307#4316#0" expanded="true" />
|
||||
<element signature="e#5559#5568#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -53,7 +53,7 @@ class Point {
|
||||
|
||||
// equals() method for testing equality of two Point() objects
|
||||
// positional untyped equality test, see fullEquals()
|
||||
boolean equals(Point other) {
|
||||
private boolean equals(Point other) {
|
||||
return this.x == other.x && this.y == other.y;
|
||||
}
|
||||
|
||||
@@ -94,9 +94,7 @@ class Point {
|
||||
// Represents a checkers checkerboard
|
||||
class CheckerBoard {
|
||||
// Offsets
|
||||
private List<Point> team1offsets = Point.asList(new int[][]{{-1, -1}, {1, -1}});
|
||||
private List<Point> team2offsets = Point.asList(new int[][]{{1, 1}, {-1, 1}});
|
||||
// private List<Point> offsets = Point.asList(new int[][]{{1, 1}, {-1, -1}, {-1, 1}, {1, -1}});
|
||||
private List<Point> offsets = Point.asList(new int[][]{{-1, -1}, {1, -1}, {1, 1}, {-1, 1}});
|
||||
private Point[][] matrix;
|
||||
// Team Constants, Team1 is default team.
|
||||
private String team1 = "R";
|
||||
@@ -113,57 +111,45 @@ class CheckerBoard {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String result = "";
|
||||
String[] result = new String[this.matrix.length];
|
||||
for(int x = 0; x < this.matrix.length; x++) {
|
||||
String[] temp = new String[this.matrix[x].length];
|
||||
for(int y = 0; y < this.matrix[x].length; y++) {
|
||||
temp[y] = this.matrix[x][y].type.equals("") ? " " : this.matrix[x][y].type; }
|
||||
result += String.join(" - ", temp) + "\n";
|
||||
result[x] = String.join(" - ", temp);
|
||||
}
|
||||
return result;
|
||||
return String.join("\n", result);
|
||||
}
|
||||
|
||||
public static boolean inBounds(Point point) {return CheckerBoard.inBounds(point.x, point.y);}
|
||||
public static boolean inBounds(int x, int y) {return x >= 0 && y >= 0 && x < 8 && y < 8;}
|
||||
Point getPoint(Point point) {return this.matrix[point.x][point.y];}
|
||||
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;}
|
||||
private Point getPoint(Point point) {return this.matrix[point.x][point.y];}
|
||||
String getType(Point point) {return this.matrix[point.x][point.y].type;}
|
||||
boolean isReverse(Point first, Point second) {return (first.type.equals(team1) && second.type.equals(team2)) || (first.type.equals(team2) && second.type.equals(team1));}
|
||||
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
|
||||
List<Point> getCheckers(String type) {
|
||||
private List<Point> getCheckers(String type) {
|
||||
List<Point> found = new ArrayList<Point>();
|
||||
for(int x = 0; x < this.matrix.length; x++) {
|
||||
for(int y = 0; y < this.matrix[x].length; y++) {
|
||||
if(this.matrix[x][y].type.equals(type))
|
||||
found.add(this.matrix[x][y]);
|
||||
for (Point[] aMatrix : this.matrix) {
|
||||
for(Point anAMatrix : aMatrix) {
|
||||
if(anAMatrix.type.equals(type))
|
||||
found.add(anAMatrix);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
List<Point> getOffsets(Point point) {
|
||||
if(point.type.equals(team1))
|
||||
return team1offsets;
|
||||
else if(point.type.equals(team2))
|
||||
return team2offsets;
|
||||
else {
|
||||
out.println(String.format("Invalid Team Type Detected - \"%s\"", point.type));
|
||||
List<Point> offsets = new ArrayList<Point>();
|
||||
offsets.addAll(team1offsets);
|
||||
offsets.addAll(team2offsets);
|
||||
return offsets;
|
||||
}
|
||||
}
|
||||
|
||||
int getMaxJumps(Point point) {
|
||||
private int getMaxJumps(Point point) {
|
||||
List<Point> previous = new ArrayList<Point>();
|
||||
previous.add(point);
|
||||
return getMaxJumps(point, 0, previous);
|
||||
}
|
||||
int getMaxJumps(Point point, int score, List<Point> previous) {
|
||||
private int getMaxJumps(Point point, int score, List<Point> previous) {
|
||||
List<Integer> offsetScores = new ArrayList<Integer>();
|
||||
offsetScores.add(score);
|
||||
for(Point offset : this.getOffsets(point)) {
|
||||
for(Point offset : this.offsets) {
|
||||
if(offset.x == 1)
|
||||
continue;
|
||||
Point newPoint = point.merge(offset);
|
||||
// Ensure new point is in matrix bounds
|
||||
if(CheckerBoard.inBounds(newPoint)) {
|
||||
@@ -189,8 +175,8 @@ class CheckerBoard {
|
||||
}
|
||||
|
||||
// Scanning methods for best jumps
|
||||
String scan() {return this.scan(this.team1);} // default to Red checkers
|
||||
String scan(String team) {
|
||||
public String scan() {return this.scan(this.team1);} // default to Red checkers
|
||||
public String scan(String team) {
|
||||
List<Point> entries = getCheckers(team);
|
||||
List<Integer> jumps = new ArrayList<Integer>();
|
||||
// Scan each entry point for jumps
|
||||
@@ -231,7 +217,6 @@ class problem12 {
|
||||
|
||||
CheckerBoard cb = new CheckerBoard(rawMatrix);
|
||||
out.println(cb);
|
||||
|
||||
out.println(cb.scan());
|
||||
}
|
||||
|
||||
|
||||
5
uil/october-2013/README.md
Normal file
5
uil/october-2013/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# october-2013
|
||||
|
||||
A+ Computer Science October 2013
|
||||
|
||||
Computer Science Competition Hands-On Programming Set
|
||||
Reference in New Issue
Block a user