Grid Challenge Discussions | | HackerRank

Grid Challenge

Sort by

recency

|

464 Discussions

|

  • + 0 comments

    some of the test data sets are not squares

  • + 0 comments

    Unless I'm missing something, I think the instructions need to be fixed. The instructions say it's a square, word 3, line 1. But it's not. Even if you filter for what should be considered "bad input" (input that isn't a square) and return "NO" it doesn't work. It's expected that rectangles are accepted as valid input.

  • + 1 comment

    anyone know why i get an index error on grid[i][j]??

    n = len(grid)
    
    for i in range(n): # go by row
        # sort row
        #print(f"unsorted row: {grid[i]}")
        row = list(grid[i])
        row.sort()
        row = ''.join(row)
        #print(f"sorted row: {row}")
    
        grid[i] = row
        print(f"sorted row: {grid[i]}")
        if i == 0:
            continue
    
        # check columns
        j = 0
        while j < n:
            print(f"i: {i}, j: {j}")
            print(f"grid[i][j]: {grid[i][j]}")
    
            if grid[i][j] < grid[i-1][j]: # if cur < prev -> False
                return "NO"
            j += 1
    
    return "YES"
    
  • + 1 comment

    Can't understand why test case 10 is getting an error....

  • + 1 comment

    Be careful because an array is not a square. Errors will occur if you handle the array as a square.