Organizing Containers of Balls

  • + 0 comments

    My idea consists of verifying if the number of balls of each type is equal to the number of spaces in each box.

    Python Code

    def organizingContainers(container):
        
        total_spaces = sorted(list(map(sum, container)))
        total_balls = sorted(list(map(sum, zip(*container))))
        
        if total_spaces == total_balls:
            return 'Possible'
        else:
            return 'Impossible'