Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Homework1 {
- public static boolean isConsecutiveFour(int[][] values){
- for(int r = 0; r < values.length; r++){
- for(int c = 0; c < values[r].length; c++){
- int position = values[r][c];
- if((values[r][c + 1] == position) && (values[r][c + 2] == position) && (values[r][c + 3] == position))
- return true;
- if((values[r+1][c] == position) && (values[r+2][c] == position) && (values[r+3][c] == position))
- return true;
- if((values[r+1][c+1] == position) && (values[r+2][c+2] == position) && (values[r+3][c+3] == position))
- return true;
- if((values[r+1][c-1] == position) && (values[r+2][c-2] == position) && (values[r+3][c-3] == position))
- return true;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement