def maxPoints(self, points):
        maxa = -1<<32
        length = len(points)
        if (length<=1):
            return length

        for i in xrange(length):
            hash_map = {}
            duplicate = 1 # point_i itself
            for j in xrange(length):
                if i==j:
                    continue

                point1 = points[i]
                point2 = points[j]
                if point1.x==point2.x and point1.y==point2.y:
                    duplicate += 1
                    continue
                if point1.x==point2.x:
                    key = 1<<32
                else:
                    slope = float(point1.y-point2.y)/(point1.x-point2.x)
                    slope = int(slope*10000) # avoid numeric errors
                    # no need to calculate intersection. During this iteration, all lines pass point1
                    key = slope

                if key not in hash_map:
                    hash_map[key] = 0
                hash_map[key]+=1


            if hash_map:
                max_key = max(hash_map, key=hash_map.get)
                max_value = hash_map[max_key]
            else:
                max_value  = 0
            maxa = max(maxa, max_value+duplicate)

        return maxa
reference: http://fisherlei.blogspot.sg/2013/12/leetcode-max-points-on-line-solution.html
dataset/ETHPy150Open algorhythms/LeetCode/149 Max Points on a Line.py/Solution.maxPoints