<commit_before>class Solution(object):
    def minTotalDistance(self, grid):
        """
        :type grid: List[List[int]]
        :rtype: int
        """
        # basically try to solve for median for 1D array twice
        vertical_list = []
        horizontal_list = []
        for i in range(len(grid)):
            for j in range(len(grid[0])):
                if grid[i][j]:
                    vertical_list += i,
                    horizontal_list += j,
        horizontal_list.sort()
        v,h = self.solveFor1D(vertical_list), self.solveFor1D(horizontal_list)
        result = 0
        for i in range(len(grid)):
            for j in range(len(grid[0])):
                if grid[i][j]:
                    result += abs(v-i) + abs(h-j)
        return result
    
    def solveFor1D(self,l):
        length = len(l)
        return l[length//2]
<commit_msg>296 better method<commit_after>class Solution(object):
    def minTotalDistance(self, grid):
        """
        :type grid: List[List[int]]
        :rtype: int
        """
        # basically try to solve for median for 1D array twice
        vertical_list = []
        horizontal_list = []
        for i in range(len(grid)):
            for j in range(len(grid[0])):
                if grid[i][j]:
                    vertical_list += i,
                    horizontal_list += j,
        horizontal_list.sort()
        result = 0
        while len(vertical_list) > 1:
            result += vertical_list.pop(-1) - vertical_list.pop(0)
            result += horizontal_list.pop(-1) - horizontal_list.pop(0)
        return result
{'fraction_non_alphanumeric': 0.11617738913179262, 'fraction_numerical': 0.011867582760774516, 'mean_word_length': 1.6655574043261232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2480796', 'n_tokens_mistral': 473, 'n_tokens_neox': 457, 'n_words': 115}