|
|
|
@ -11,8 +11,7 @@ import java.util.Scanner;
|
|
|
|
|
*/
|
|
|
|
|
public class MP1_CalebFontenot {
|
|
|
|
|
|
|
|
|
|
public static int[][] inputArray()
|
|
|
|
|
{
|
|
|
|
|
public static int[][] inputArray() {
|
|
|
|
|
int m, n, i, j;
|
|
|
|
|
// Create scanner
|
|
|
|
|
Scanner input = new Scanner(System.in);
|
|
|
|
@ -43,8 +42,7 @@ public class MP1_CalebFontenot {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isConsecutiveFour(int[] values)
|
|
|
|
|
{
|
|
|
|
|
public static boolean isConsecutiveFour(int[] values) {
|
|
|
|
|
for (int i = 0; i < values.length - 4; ++i) {
|
|
|
|
|
if (values[i] == values[i + 1]
|
|
|
|
|
&& values[i + 1] == values[i + 2]
|
|
|
|
@ -57,8 +55,7 @@ public class MP1_CalebFontenot {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args)
|
|
|
|
|
{ //2965
|
|
|
|
|
public static void main(String[] args) { //2965
|
|
|
|
|
int[][] horizontalTestArray = { // Horizontal
|
|
|
|
|
{0, 1, 0, 3, 1, 6, 1},
|
|
|
|
|
{0, 1, 6, 8, 6, 0, 1},
|
|
|
|
@ -143,8 +140,7 @@ public class MP1_CalebFontenot {
|
|
|
|
|
//System.out.println(isConsecutiveFour(intArray1));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void printArray(int[][] array)
|
|
|
|
|
{
|
|
|
|
|
public static void printArray(int[][] array) {
|
|
|
|
|
int rowCounter = 0;
|
|
|
|
|
for (int x = 0; x < array.length; x++) {
|
|
|
|
|
for (int y = 0; y < array[x].length; y++) {
|
|
|
|
@ -157,41 +153,33 @@ public class MP1_CalebFontenot {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void printArray(int[] array)
|
|
|
|
|
{
|
|
|
|
|
public static void printArray(int[] array) {
|
|
|
|
|
for (int i : array) {
|
|
|
|
|
System.out.print(i + " ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isConsecutiveFour(int[][] values)
|
|
|
|
|
{
|
|
|
|
|
int intCounter = 0, y = 0;
|
|
|
|
|
// Horizontal checking
|
|
|
|
|
// If the same value has been observed 4 times, return true
|
|
|
|
|
//System.out.println("values[0].length: " + values[0].length);
|
|
|
|
|
//System.out.println("values.length: " + values.length);
|
|
|
|
|
public static boolean isConsecutiveFour(int[][] values) {
|
|
|
|
|
// Horizontal Checking
|
|
|
|
|
System.out.println("Checking for Horizontal matches...");
|
|
|
|
|
for (int rowIterate = 0; rowIterate < values.length; ++rowIterate) {
|
|
|
|
|
y = 0;
|
|
|
|
|
for (int x = 0; x < values[0].length - 1; ++x) {
|
|
|
|
|
++y;
|
|
|
|
|
if (values[rowIterate][x] == values[rowIterate][y]) {
|
|
|
|
|
intCounter++;
|
|
|
|
|
System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter);
|
|
|
|
|
} else {
|
|
|
|
|
intCounter = 0;
|
|
|
|
|
System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter);
|
|
|
|
|
}
|
|
|
|
|
if (intCounter == 3) {
|
|
|
|
|
System.out.println("Horizontal match!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("Checking next line...");
|
|
|
|
|
}
|
|
|
|
|
boolean horizontalTest = horizontalMatch(values);
|
|
|
|
|
// Vertical Checking
|
|
|
|
|
System.out.println("Checking for Vertical matches...");
|
|
|
|
|
boolean verticalTest = verticalMatch(values);
|
|
|
|
|
System.out.println("Checking for Diagonal matches...");
|
|
|
|
|
boolean diagonalNorthwest = MarkouCode.topLeftTriangleDiagonalNothwest(values);
|
|
|
|
|
boolean diagonalMiddle = MarkouCode.bottomRightTriangleDiagonalNothwest(values);
|
|
|
|
|
System.out.println(diagonalNorthwest);
|
|
|
|
|
if (horizontalTest || verticalTest || diagonalNorthwest) {
|
|
|
|
|
System.out.println("Match found!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
System.out.println("No match found.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean verticalMatch(int[][] values) {
|
|
|
|
|
int intCounter = 0, y = 0;
|
|
|
|
|
for (int rowIterate = 0; rowIterate < values.length; ++rowIterate) {
|
|
|
|
|
y = 0;
|
|
|
|
|
for (int x = 0; x < values.length - 1; ++x) {
|
|
|
|
@ -210,26 +198,33 @@ public class MP1_CalebFontenot {
|
|
|
|
|
}
|
|
|
|
|
System.out.println("Checking next line...");
|
|
|
|
|
}
|
|
|
|
|
System.out.println("Checking for Diagonal matches...");
|
|
|
|
|
int rows = 0;
|
|
|
|
|
for (int numColumns = 0; numColumns < values[0].length; numColumns++) {
|
|
|
|
|
int i = 0;
|
|
|
|
|
int j = numColumns;
|
|
|
|
|
int[] _1DArray = new int[numColumns + 1];
|
|
|
|
|
for (int numRows = 0; numRows <= rows; ++numRows) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
public static boolean horizontalMatch(int[][] values) {
|
|
|
|
|
int intCounter = 0, y = 0;
|
|
|
|
|
// Horizontal checking
|
|
|
|
|
// If the same value has been observed 4 times, return true
|
|
|
|
|
//System.out.println("values[0].length: " + values[0].length);
|
|
|
|
|
//System.out.println("values.length: " + values.length);
|
|
|
|
|
|
|
|
|
|
System.out.println("i: " + i + " j: " + j);
|
|
|
|
|
_1DArray[numRows] = values[i][j];
|
|
|
|
|
//printArray(_1DArray);
|
|
|
|
|
//System.out.println(values[rows][i] + " " + values[rows][j]);
|
|
|
|
|
++i;
|
|
|
|
|
--j;
|
|
|
|
|
for (int rowIterate = 0; rowIterate < values.length; ++rowIterate) {
|
|
|
|
|
y = 0;
|
|
|
|
|
for (int x = 0; x < values[0].length - 1; ++x) {
|
|
|
|
|
++y;
|
|
|
|
|
if (values[rowIterate][x] == values[rowIterate][y]) {
|
|
|
|
|
intCounter++;
|
|
|
|
|
System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter);
|
|
|
|
|
} else {
|
|
|
|
|
intCounter = 0;
|
|
|
|
|
System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter);
|
|
|
|
|
}
|
|
|
|
|
if (intCounter == 3) {
|
|
|
|
|
System.out.println("Horizontal match!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
System.out.println("Checking next line...");
|
|
|
|
|
rows++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("No match found.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|