Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Custom User Avatar

    For the record, OPs wrong solution is:

    public class Solution{
      public static String diagonal(int[][] matrix){
        System.out.println(matrix[0][0]+" "+matrix[0][1]+" "+matrix[0][2]);
                System.out.println(matrix[1][0]+" "+matrix[1][1]+" "+matrix[1][2]);
                System.out.println(matrix[2][0]+" "+matrix[2][1]+" "+matrix[2][2]);
                System.out.println(matrix[0][0] + matrix[2][2] > matrix[0][2] + matrix[2][0] ? "Principal Diagonal win!" :
              matrix[0][0] + matrix[2][2] < matrix[0][2] + matrix[2][0] ? "Secondary Diagonal win!" : "Draw!");
        return matrix[0][0] + matrix[2][2] > matrix[0][2] + matrix[2][0] ? "Principal Diagonal win!" :
              matrix[0][0] + matrix[2][2] < matrix[0][2] + matrix[2][0] ? "Secondary Diagonal win!" : "Draw!";
      }
    }
    

    Example input it fails is:

    matrix = [
      [1, 6, 1, 4, 9]
      [7, 2, 6, 2, 9]
      [1, 4, 8, 6, 5]
      [1, 6, 0, 1, 4]
      [1, 2, 5, 4, 1]
    ]
    
  • Custom User Avatar

    Your solution is shit broken, it can handle only matrices of size 3x3. It returns wrong result for matrices larger than 3x3.

    Not a kata issue.

  • Default User Avatar

    Shit ain't working

    5 0 4
    9 2 0
    3 6 4
    Principal Diagonal win!

    right? according to the rules, it is. according to the random tests, secondary wins here though...